1 From 4bf93b50fd04118ac7f33a3c2b8a0a1f9fa80bc9 Mon Sep 17 00:00:00 2001
2 From: Vyacheslav Dubeyko <slava@dubeyko.com>
3 Date: Thu, 22 Aug 2013 16:35:45 -0700
4 Subject: nilfs2: fix issue with counting number of bio requests for BIO_EOPNOTSUPP error detection
6 From: Vyacheslav Dubeyko <slava@dubeyko.com>
8 commit 4bf93b50fd04118ac7f33a3c2b8a0a1f9fa80bc9 upstream.
10 Fix the issue with improper counting number of flying bio requests for
11 BIO_EOPNOTSUPP error detection case.
13 The sb_nbio must be incremented exactly the same number of times as
14 complete() function was called (or will be called) because
15 nilfs_segbuf_wait() will call wail_for_completion() for the number of
19 wait_for_completion(&segbuf->sb_bio_event);
20 } while (--segbuf->sb_nbio > 0);
22 Two functions complete() and wait_for_completion() must be called the
23 same number of times for the same sb_bio_event. Otherwise,
24 wait_for_completion() will hang or leak.
26 Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
27 Cc: Dan Carpenter <dan.carpenter@oracle.com>
28 Acked-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
29 Tested-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
30 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
31 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 fs/nilfs2/segbuf.c | 2 +-
36 1 file changed, 1 insertion(+), 1 deletion(-)
38 --- a/fs/nilfs2/segbuf.c
39 +++ b/fs/nilfs2/segbuf.c
40 @@ -376,12 +376,12 @@ static int nilfs_segbuf_submit_bio(struc
41 bio->bi_private = segbuf;
43 submit_bio(mode, bio);
45 if (bio_flagged(bio, BIO_EOPNOTSUPP)) {