Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fuse: fixed WARNING:at_fs/fuse/file.c:#tree_insert[fuse]
       [not found] <ea00a67e-5a61-2e70-215e-004e3dcc57c1@virtuozzo.com>
@ 2020-06-15  7:19 ` Vasily Averin
  0 siblings, 0 replies; only message in thread
From: Vasily Averin @ 2020-06-15  7:19 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel, Maxim Patlasov

kernel test robot <rong.a.chen@intel.com> 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@intel.com>
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-15  7:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ea00a67e-5a61-2e70-215e-004e3dcc57c1@virtuozzo.com>
2020-06-15  7:19 ` [PATCH] fuse: fixed WARNING:at_fs/fuse/file.c:#tree_insert[fuse] Vasily Averin

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).