* [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page()
@ 2007-05-10 14:33 David Howells
2007-05-10 14:33 ` [PATCH 2/2] AFS: Fix a couple of problems with unlinking AFS files David Howells
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: David Howells @ 2007-05-10 14:33 UTC (permalink / raw)
To: akpm, netdev; +Cc: linux-kernel, linux-fsdevel, dhowells
Following bug was uncovered by compiling with '-W' flag:
CC [M] fs/afs/write.o
fs/afs/write.c: In function ‘afs_write_back_from_locked_page’:
fs/afs/write.c:398: warning: comparison of unsigned expression >= 0 is always true
Loop variable 'n' is unsigned, so wraps around happily as far as I can
see. Trival fix attached (compile tested only).
Signed-Off-By: Mika Kukkonen <mikukkon@iki.fi>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/write.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 67ae4db..28f3751 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -395,8 +395,9 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
if (n == 0)
goto no_more;
if (pages[0]->index != start) {
- for (n--; n >= 0; n--)
- put_page(pages[n]);
+ do {
+ put_page(pages[--n]);
+ } while (n > 0);
goto no_more;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/2] AFS: Fix a couple of problems with unlinking AFS files 2007-05-10 14:33 [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() David Howells @ 2007-05-10 14:33 ` David Howells 2007-05-10 23:19 ` [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() Andrew Morton ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: David Howells @ 2007-05-10 14:33 UTC (permalink / raw) To: akpm, netdev; +Cc: linux-kernel, linux-fsdevel, dhowells Fix a couple of problems with unlinking AFS files. (1) The parent directory wasn't being updated properly between unlink() and the following lookup(). It seems that, for some reason, invalidate_remote_inode() wasn't discarding the directory contents correctly, so this patch calls invalidate_inode_pages2() instead on non-regular files. (2) afs_vnode_deleted_remotely() should handle vnodes that don't have a source server recorded without oopsing. Signed-off-by: David Howells <dhowells@redhat.com> --- fs/afs/file.c | 2 +- fs/afs/inode.c | 10 +++++++--- fs/afs/super.c | 3 ++- fs/afs/vnode.c | 33 +++++++++++++++++++++------------ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/fs/afs/file.c b/fs/afs/file.c index 3e25795..9c0e721 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -236,7 +236,7 @@ static void afs_invalidatepage(struct page *page, unsigned long offset) { int ret = 1; - kenter("{%lu},%lu", page->index, offset); + _enter("{%lu},%lu", page->index, offset); BUG_ON(!PageLocked(page)); diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 515a5d1..47f5fed 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -209,11 +209,15 @@ bad_inode: */ void afs_zap_data(struct afs_vnode *vnode) { - _enter("zap data {%x:%u}", vnode->fid.vid, vnode->fid.vnode); + _enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode); /* nuke all the non-dirty pages that aren't locked, mapped or being - * written back */ - invalidate_remote_inode(&vnode->vfs_inode); + * written back in a regular file and completely discard the pages in a + * directory or symlink */ + if (S_ISREG(vnode->vfs_inode.i_mode)) + invalidate_remote_inode(&vnode->vfs_inode); + else + invalidate_inode_pages2(vnode->vfs_inode.i_mapping); } /* diff --git a/fs/afs/super.c b/fs/afs/super.c index d24be33..422f532 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c @@ -488,6 +488,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb) vnode->flags = 1 << AFS_VNODE_UNSET; vnode->cb_promised = false; + _leave(" = %p", &vnode->vfs_inode); return &vnode->vfs_inode; } @@ -498,7 +499,7 @@ static void afs_destroy_inode(struct inode *inode) { struct afs_vnode *vnode = AFS_FS_I(inode); - _enter("{%lu}", inode->i_ino); + _enter("%p{%x:%u}", inode, vnode->fid.vid, vnode->fid.vnode); _debug("DESTROY INODE %p", inode); diff --git a/fs/afs/vnode.c b/fs/afs/vnode.c index ec81466..bea8bd9 100644 --- a/fs/afs/vnode.c +++ b/fs/afs/vnode.c @@ -175,24 +175,33 @@ static void afs_vnode_deleted_remotely(struct afs_vnode *vnode) { struct afs_server *server; + _enter("{%p}", vnode->server); + set_bit(AFS_VNODE_DELETED, &vnode->flags); server = vnode->server; - if (vnode->cb_promised) { - spin_lock(&server->cb_lock); + if (server) { if (vnode->cb_promised) { - rb_erase(&vnode->cb_promise, &server->cb_promises); - vnode->cb_promised = false; + spin_lock(&server->cb_lock); + if (vnode->cb_promised) { + rb_erase(&vnode->cb_promise, + &server->cb_promises); + vnode->cb_promised = false; + } + spin_unlock(&server->cb_lock); } - spin_unlock(&server->cb_lock); - } - spin_lock(&vnode->server->fs_lock); - rb_erase(&vnode->server_rb, &vnode->server->fs_vnodes); - spin_unlock(&vnode->server->fs_lock); + spin_lock(&server->fs_lock); + rb_erase(&vnode->server_rb, &server->fs_vnodes); + spin_unlock(&server->fs_lock); - vnode->server = NULL; - afs_put_server(server); + vnode->server = NULL; + afs_put_server(server); + } else { + ASSERT(!vnode->cb_promised); + } + + _leave(""); } /* @@ -225,7 +234,7 @@ void afs_vnode_finalise_status_update(struct afs_vnode *vnode, */ static void afs_vnode_status_update_failed(struct afs_vnode *vnode, int ret) { - _enter("%p,%d", vnode, ret); + _enter("{%x:%u},%d", vnode->fid.vid, vnode->fid.vnode, ret); spin_lock(&vnode->lock); ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() 2007-05-10 14:33 [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() David Howells 2007-05-10 14:33 ` [PATCH 2/2] AFS: Fix a couple of problems with unlinking AFS files David Howells @ 2007-05-10 23:19 ` Andrew Morton 2007-05-11 9:49 ` David Howells 2007-05-11 9:57 ` David Howells 3 siblings, 0 replies; 7+ messages in thread From: Andrew Morton @ 2007-05-10 23:19 UTC (permalink / raw) To: David Howells; +Cc: netdev, linux-kernel, linux-fsdevel On Thu, 10 May 2007 15:33:34 +0100 David Howells <dhowells@redhat.com> wrote: > Following bug was uncovered by compiling with '-W' flag: gcc -W finds a number of fairly scary bugs. More than one would expect, given that it is recommended in Documentation/SubmitChecklist, which everyone reads ;) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() 2007-05-10 14:33 [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() David Howells 2007-05-10 14:33 ` [PATCH 2/2] AFS: Fix a couple of problems with unlinking AFS files David Howells 2007-05-10 23:19 ` [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() Andrew Morton @ 2007-05-11 9:49 ` David Howells 2007-05-11 9:58 ` Andrew Morton 2007-05-11 10:03 ` David Howells 2007-05-11 9:57 ` David Howells 3 siblings, 2 replies; 7+ messages in thread From: David Howells @ 2007-05-11 9:49 UTC (permalink / raw) To: Andrew Morton; +Cc: netdev, linux-kernel, linux-fsdevel Andrew Morton <akpm@linux-foundation.org> wrote: > > Following bug was uncovered by compiling with '-W' flag: > > gcc -W finds a number of fairly scary bugs. Do you mean in my code specifically? Or in the kernel in general? As far as I can tell -W only finds an eye-glazingly large quantity of 'unused parameter' warnings in AFS and AF_RXRPC. David ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() 2007-05-11 9:49 ` David Howells @ 2007-05-11 9:58 ` Andrew Morton 2007-05-11 10:03 ` David Howells 1 sibling, 0 replies; 7+ messages in thread From: Andrew Morton @ 2007-05-11 9:58 UTC (permalink / raw) To: David Howells; +Cc: netdev, linux-kernel, linux-fsdevel On Fri, 11 May 2007 10:49:23 +0100 David Howells <dhowells@redhat.com> wrote: > Andrew Morton <akpm@linux-foundation.org> wrote: > > > > Following bug was uncovered by compiling with '-W' flag: > > > > gcc -W finds a number of fairly scary bugs. > > Do you mean in my code specifically? Or in the kernel in general? In general. > As far as > I can tell -W only finds an eye-glazingly large quantity of 'unused parameter' > warnings in AFS and AF_RXRPC. Yes, it's a shame that there doesn't seem to be a fine-grained way of turning on -W's useful bits. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() 2007-05-11 9:49 ` David Howells 2007-05-11 9:58 ` Andrew Morton @ 2007-05-11 10:03 ` David Howells 1 sibling, 0 replies; 7+ messages in thread From: David Howells @ 2007-05-11 10:03 UTC (permalink / raw) To: Andrew Morton; +Cc: netdev, linux-kernel, linux-fsdevel Andrew Morton <akpm@linux-foundation.org> wrote: > Yes, it's a shame that there doesn't seem to be a fine-grained way of > turning on -W's useful bits. You can turn off -W's undesirable bits. For net/rxrpc/ and fs/afs/ at least, adding: CFLAGS += -W -Wno-unused-parameter to the Makefile generates no warnings. Perhaps this should be added to the master Makefile. Adding -Wsign-compare finds some stuff that I will fix. It also finds some stuff in the main and the networking headers. This is a really useful option and found some tricky bugs in CacheFiles. I would endorse adding this generally too. David ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() 2007-05-10 14:33 [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() David Howells ` (2 preceding siblings ...) 2007-05-11 9:49 ` David Howells @ 2007-05-11 9:57 ` David Howells 3 siblings, 0 replies; 7+ messages in thread From: David Howells @ 2007-05-11 9:57 UTC (permalink / raw) To: Andrew Morton; +Cc: netdev, linux-kernel, linux-fsdevel Andrew Morton <akpm@linux-foundation.org> wrote: > More than one would expect, given that it is recommended in > Documentation/SubmitChecklist, which everyone reads ;) Which states incorrectly: | 22: Newly-added code has been compiled with `gcc -W'. This will generate | lots of noise, but is good for finding bugs like "warning: comparison | between signed and unsigned". -W does not imply -Wsign-compare, at least not on my gcc. David ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-05-11 10:03 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-05-10 14:33 [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() David Howells 2007-05-10 14:33 ` [PATCH 2/2] AFS: Fix a couple of problems with unlinking AFS files David Howells 2007-05-10 23:19 ` [PATCH 1/2] AFS: Fix interminable loop in afs_write_back_from_locked_page() Andrew Morton 2007-05-11 9:49 ` David Howells 2007-05-11 9:58 ` Andrew Morton 2007-05-11 10:03 ` David Howells 2007-05-11 9:57 ` David Howells
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).