]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
c199e876b72d6404b3050385a38308858b6c9554
[thirdparty/kernel/stable-queue.git] /
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
5
6 From: Vyacheslav Dubeyko <slava@dubeyko.com>
7
8 commit 4bf93b50fd04118ac7f33a3c2b8a0a1f9fa80bc9 upstream.
9
10 Fix the issue with improper counting number of flying bio requests for
11 BIO_EOPNOTSUPP error detection case.
12
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
16 times set to sb_nbio:
17
18 do {
19 wait_for_completion(&segbuf->sb_bio_event);
20 } while (--segbuf->sb_nbio > 0);
21
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.
25
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>
33
34 ---
35 fs/nilfs2/segbuf.c | 2 +-
36 1 file changed, 1 insertion(+), 1 deletion(-)
37
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;
42 bio_get(bio);
43 submit_bio(mode, bio);
44 + segbuf->sb_nbio++;
45 if (bio_flagged(bio, BIO_EOPNOTSUPP)) {
46 bio_put(bio);
47 err = -EOPNOTSUPP;
48 goto failed;
49 }
50 - segbuf->sb_nbio++;
51 bio_put(bio);
52
53 wi->bio = NULL;