Skip to contentSkip to conversation

nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption

PATCH In review Dan Carpenter 4 participants 5 messages Apr 25, 2013 2 messages not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

[ It's weird that kbuild didn't catch this ].

Hello Vyacheslav Dubeyko,

The patch bb594c4767b0: "nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption" from Apr 18, 2013, leads to the following warning:
"fs/nilfs2/inode.c:211 nilfs_writepage()
error: we previously assumed 'inode' could be null (see line 195)"

fs/nilfs2/inode.c
190 static int nilfs_writepage(struct page *page, struct writeback_control *wbc) 191 {
192 struct inode *inode = page->mapping->host;
193 int err;
194

   195          if (inode && (inode->i_sb->s_flags & MS_RDONLY)) {
                    ^^^^^

New check.

196 /*

   197                   * It means that filesystem was remounted in read-only
   198                   * mode because of error or metadata corruption. But we
   199                   * have dirty pages that try to be flushed in background.
   200                   * So, here we simply discard this dirty page.
   201                   */
   202                  nilfs_clear_dirty_page(page, false);
   203                  unlock_page(page);
   204                  return -EROFS;
   205          }
   206  
   207          redirty_page_for_writepage(wbc, page);
   208          unlock_page(page);
   209  
   210          if (wbc->sync_mode == WB_SYNC_ALL) {
   211                  err = nilfs_construct_segment(inode->i_sb);
                                                      ^^^^^^^^^^^

Old dereference.

212 if (unlikely(err))
213 return err;
214 } else if (wbc->for_reclaim)

   215                  nilfs_flush_segment(inode->i_sb, inode->i_ino);
                                            ^^^^^^^^^^^

Old dereference.

216
217 return 0;
218 }

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 nilfs2: fix warning in nilfs_writepage()

Quoted 11 lines · Dan Carpenter

[ It's weird that kbuild didn't catch this ].

Hello Vyacheslav Dubeyko,

The patch bb594c4767b0: "nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption" from Apr 18, 2013, leads to the following warning:
"fs/nilfs2/inode.c:211 nilfs_writepage()
error: we previously assumed 'inode' could be null (see line 195)"

Please, find below the patch with fix.

Thanks,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] nilfs2: fix warning in nilfs_writepage()

The patch fixes warning: "fs/nilfs2/inode.c:211 nilfs_writepage() error: we previously assumed 'inode' could be null (see line 195)".

---
 fs/nilfs2/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/inode.c +1 -1
index ba7a1da..cf02f55 100644
@@ -192,7 +192,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
 	struct inode *inode = page->mapping->host;
 	int err;
 
-	if (inode && (inode->i_sb->s_flags & MS_RDONLY)) {
+	if (inode->i_sb->s_flags & MS_RDONLY) {
 		/*
 		 * It means that filesystem was remounted in read-only
 		 * mode because of error or metadata corruption. But we
Signature · 8 lines
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Re: [PATCH] nilfs2: fix warning in nilfs_writepage()

Quoted 15 lines · On Thu, 25 Apr 2013 13:38:35 +0400 Vyacheslav Dubeyko…
Quoted 11 lines · Dan Carpenter

[ It's weird that kbuild didn't catch this ].

Hello Vyacheslav Dubeyko,

The patch bb594c4767b0: "nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption" from Apr 18, 2013, leads to the following warning:
"fs/nilfs2/inode.c:211 nilfs_writepage()
error: we previously assumed 'inode' could be null (see line 195)"

Please, find below the patch with fix.

Quoted 7 lines

Thanks,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] nilfs2: fix warning in nilfs_writepage()

The patch fixes warning: "fs/nilfs2/inode.c:211 nilfs_writepage() error: we previously assumed 'inode' could be null (see line 195)".

The changelog doesn't tell us what tool emitted the warning. Was it sparse?

fs/nilfs2/inode.c static int nilfs_writepage(struct page *page, struct writeback_control *wbc) · line 198

Quoted 11 lines
fs/nilfs2/inode.c +1 -1
@@ -192,7 +192,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)
 	struct inode *inode = page->mapping->host;
 	int err;
 
-	if (inode && (inode->i_sb->s_flags & MS_RDONLY)) {
+	if (inode->i_sb->s_flags & MS_RDONLY) {
 		/*
 		 * It means that filesystem was remounted in read-only
 		 * mode because of error or metadata corruption. But we

I'll going to fix up the patch description and subject. In particular, the objective of this patch isn't really to fix a warning - it's to remove some unneeded code. The warning merely alerted us to its presence.

From: Vyacheslav Dubeyko <[email protected]>
Subject: nilfs2: remove unneeded test in nilfs_writepage()

page->mapping->host cannot be NULL in nilfs_writepage(), so remove the unneeded test.

The fixes the sparse warning: "fs/nilfs2/inode.c:211 nilfs_writepage()
error: we previously assumed 'inode' could be null (see line 195)".

---

 fs/nilfs2/inode.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/inode.c renamed from fs/nilfs2/inode.c~nilfs2-fix-warning-in-nilfs_writepage +1 -1
diff -puN fs/nilfs2/inode.c~nilfs2-fix-warning-in-nilfs_writepage fs/nilfs2/inode.c
@@ -192,7 +192,7 @@ static int nilfs_writepage(struct page *
 	struct inode *inode = page->mapping->host;
 	int err;
 
-	if (inode && (inode->i_sb->s_flags & MS_RDONLY)) {
+	if (inode->i_sb->s_flags & MS_RDONLY) {
 		/*
 		 * It means that filesystem was remounted in read-only
 		 * mode because of error or metadata corruption. But we

_

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20130425134610.d26f087c0db29d0703736db3-de/[email protected]

#5 lore raw

Re: [PATCH] nilfs2: fix warning in nilfs_writepage()

Quoted 23 lines · Andrew Morton
Quoted 21 lines · On Thu, 25 Apr 2013 13:38:35 +0400 Vyacheslav Dubeyko…
Quoted 11 lines · Dan Carpenter

[ It's weird that kbuild didn't catch this ].

Hello Vyacheslav Dubeyko,

The patch bb594c4767b0: "nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption" from Apr 18, 2013, leads to the following warning:
"fs/nilfs2/inode.c:211 nilfs_writepage()
error: we previously assumed 'inode' could be null (see line 195)"

Please, find below the patch with fix.

Thanks,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] nilfs2: fix warning in nilfs_writepage()

Quoted 4 lines
Quoted 1 line

The patch fixes warning: "fs/nilfs2/inode.c:211 nilfs_writepage() error: we previously assumed 'inode' could be null (see line 195)".

The changelog doesn't tell us what tool emitted the warning. Was it sparse?

That's my fault. It's a Smatch warning.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive
Quoted 1 line · Dan Carpenter

[ It's weird that kbuild didn't catch this ].

Sorry about that! I made a big change in the test scripts and took several days to fixup the new bugs. Quite some branches missed the tests during the time..

Thanks,
Fengguang
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html