[PATCH] fuse: fixed WARNING:at_fs/fuse/file.c:#tree_insert[fuse]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kernel test robot <rong.a.chen@xxxxxxxxx> detected warning after apply of 
6b2fb79963fb ("fuse: optimize writepages search")

WARNING: CPU: 1 PID: 17211 at fs/fuse/file.c:1728 tree_insert+0xab/0xc0 [fuse]
RIP: 0010:tree_insert+0xab/0xc0 [fuse]
Call Trace:
 fuse_writepages_fill+0x5da/0x6a0 [fuse]
 write_cache_pages+0x171/0x470
 fuse_writepages+0x8a/0x100 [fuse]
 do_writepages+0x43/0xe0

It was triggered by WARN_ON(!wpa->ia.ap.num_pages) 

Though fuse_writepages_fill() calls tree_insert() with
wpa->ia.ap.num_pages = 0 and increments it a bit later.

Fixes: 6b2fb79963fb ("fuse: optimize writepages search")
Reported-by: kernel test robot <rong.a.chen@xxxxxxxxx>
Signed-off-by: Vasily Averin <vvs@xxxxxxxxxxxxx>
---
 fs/fuse/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index e573b0c..1771396 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1677,11 +1677,11 @@ void fuse_flush_writepages(struct inode *inode)
 static void tree_insert(struct rb_root *root, struct fuse_writepage_args *wpa)
 {
 	pgoff_t idx_from = wpa->ia.write.in.offset >> PAGE_SHIFT;
-	pgoff_t idx_to = idx_from + wpa->ia.ap.num_pages - 1;
+	pgoff_t idx_to = idx_from + (wpa->ia.ap.num_pages ?
+				wpa->ia.ap.num_pages - 1 : 0);
 	struct rb_node **p = &root->rb_node;
 	struct rb_node  *parent = NULL;
 
-	WARN_ON(!wpa->ia.ap.num_pages);
 	while (*p) {
 		struct fuse_writepage_args *curr;
 		pgoff_t curr_index;
-- 
1.8.3.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux