nilfs2: remove double bio_put() in nilfs_end_bio_write() for BIO_EOPNOTSUPP error
Subsystems (3)
PATCH 1/1 nilfs2: remove double bio_put() in nilfs_end_bio_write() for BIO_EOPNOTSUPP error
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] nilfs2: remove double bio_put() in nilfs_end_bio_write() for BIO_EOPNOTSUPP error
This patch removes double call of bio_put() in nilfs_end_bio_write() for the case of BIO_EOPNOTSUPP error detection. The issue was found by Dan Carpenter and he suggests first version of the fix too.
--- fs/nilfs2/segbuf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nilfs2/segbuf.c +1 -2
@@ -345,8 +345,7 @@ static void nilfs_end_bio_write(struct bio *bio, int err)if (err = -EOPNOTSUPP ) {set_bit (BIO_EOPNOTSUPP , &bio->bi_flags); -bio_put (bio); -/* to be detected by submit_seg_bio() */ +/* to be detected by nilfs_segbuf_submit_bio() */ }if (!uptodate)
Signature · 1 line
1.7.9.5
Hi Vyacheslav,
Quoted 10 lines · Vyacheslav Dubeyko
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] nilfs2: remove doublebio_put()innilfs_end_bio_write()forBIO_EOPNOTSUPPerrorThis patch removes double call of
bio_put()innilfs_end_bio_write()for the case ofBIO_EOPNOTSUPPerror detection. The issue was found by Dan Carpenter and he suggests first version of the fix too.Reported-by Dan Carpenter <[email protected]>Signed-off-by Vyacheslav Dubeyko <[email protected]>CC Ryusuke Konishi <[email protected]>
Thank you for following the issue. I reviewed the code around bio.
In conclusion, Dan Carpenter's patch looks correct because nilfs_segbuf_submit_bio() does not increment the number of flying bio (segbuf->sb_nbio) for EOPNOTSUPP/BIO_EOPNOTSUPP case.
If nilfs_end_bio_write() function reaches the complete() call for the EOPNOTSUPP/BIO_EOPNOTSUPP case (as the current implementation), the number of complete() calls and that of wait_for_complete() will not balance.
Do you have a comment?
Regards,
Ryusuke Konishi
Quoted 27 lines
--- fs/nilfs2/segbuf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/nilfs2/segbuf.c +1
-2@@ -345,8 +345,7 @@ static void nilfs_end_bio_write(struct bio *bio, int err)if (err = -EOPNOTSUPP ) {set_bit (BIO_EOPNOTSUPP , &bio->bi_flags); -bio_put (bio); -/* to be detected by submit_seg_bio() */ +/* to be detected by nilfs_segbuf_submit_bio() */ }if (!uptodate)Signature · 8 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Vyacheslav Dubeyko
maintainerHi Ryusuke,
On Tue, 2013-07-23 at 03:24 +0900, Ryusuke Konishi wrote:
[snip]
Quoted 7 lines
Thank you for following the issue. I reviewed the code around bio.
In conclusion, Dan Carpenter's patch looks correct because
nilfs_segbuf_submit_bio()does not increment the number of flying bio (segbuf->sb_nbio) for EOPNOTSUPP/BIO_EOPNOTSUPP case.
I worry that nilfs_end_bio_write() is called asynchronously. And, as I understand, the BIO_EOPNOTSUPP flag is set during nilfs_end_bio_write() call. It means for me that sometimes segbuf->sb_nbio will be not incremented in nilfs_segbuf_submit_bio() but sometimes this field can be incremented and for BIO_EOPNOTSUPP case.
Quoted 5 lines
If
nilfs_end_bio_write()function reaches thecomplete()call for the EOPNOTSUPP/BIO_EOPNOTSUPP case (as the current implementation), the number ofcomplete()calls and that ofwait_for_complete()will not balance.
I think that it is dangerous to return without complete() call because of asynchronous nature of nilfs_end_bio_write() call.
What do you think?
With the best regards,
Vyacheslav Dubeyko.
Quoted 32 lines
Do you have a comment?
Regards,
Ryusuke KonishiQuoted 27 lines
--- fs/nilfs2/segbuf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/nilfs2/segbuf.c +1
-2@@ -345,8 +345,7 @@ static void nilfs_end_bio_write(struct bio *bio, int err)if (err = -EOPNOTSUPP ) {set_bit (BIO_EOPNOTSUPP , &bio->bi_flags); -bio_put (bio); -/* to be detected by submit_seg_bio() */ +/* to be detected by nilfs_segbuf_submit_bio() */ }if (!uptodate)Signature · 8 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines · Vyacheslav Dubeyko
Hi Ryusuke,
On Tue, 2013-07-23 at 03:24 +0900, Ryusuke Konishi wrote:
[snip]
Quoted 7 lines
Thank you for following the issue. I reviewed the code around bio.
In conclusion, Dan Carpenter's patch looks correct because
nilfs_segbuf_submit_bio()does not increment the number of flying bio (segbuf->sb_nbio) for EOPNOTSUPP/BIO_EOPNOTSUPP case.I worry that
nilfs_end_bio_write()is called asynchronously. And, as I understand, theBIO_EOPNOTSUPPflag is set duringnilfs_end_bio_write()call. It means for me that sometimessegbuf->sb_nbiowill be not incremented innilfs_segbuf_submit_bio()but sometimes this field can be incremented and forBIO_EOPNOTSUPPcase.Quoted 5 lines
If
nilfs_end_bio_write()function reaches thecomplete()call for the EOPNOTSUPP/BIO_EOPNOTSUPP case (as the current implementation), the number ofcomplete()calls and that ofwait_for_complete()will not balance.
Quoted 4 lines
I think that it is dangerous to return without
complete()call because of asynchronous nature ofnilfs_end_bio_write()call.What do you think?
nilfs_end_bio_write() may be called either synchronously or asynchronously as bio->bi_end_io(). It may be called when submit_bio() fails or when bio is terminated asynchronously.
Yes, the current nilfs_end_bio_write() implementation is confusing and dangerous for the EOPNOTSUPP case.
I think nilfs_end_bio_write() should be modified so that segbuf->sb_nbio is incremented in either case.
Thanks,
Ryusuke Konishi