From: Kent Overstreet Date: Thu, 5 Aug 2021 17:02:39 +0000 (-0400) Subject: bcachefs: Fix an unhandled transaction restart X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3737e0ddfbce4791a6415fa685e235b03924ff01;p=linux.git bcachefs: Fix an unhandled transaction restart __bch2_read() -> __bch2_read_extent() -> bch2_bucket_io_time_reset() may cause a transaction restart, which we don't return an error for because it doesn't prevent us from making forward progress on the read we're submitting. Instead, change __bch2_read() and bchfs_read() to check for transaction restarts. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 30e5acd2e97c4..9ac10b72d1cf0 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -791,6 +791,15 @@ retry: unsigned bytes, sectors, offset_into_extent; enum btree_id data_btree = BTREE_ID_extents; + /* + * read_extent -> io_time_reset may cause a transaction restart + * without returning an error, we need to check for that here: + */ + if (!bch2_trans_relock(trans)) { + ret = -EINTR; + break; + } + bch2_btree_iter_set_pos(iter, POS(inum, rbio->bio.bi_iter.bi_sector)); diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index f293876e0bbc0..30d9b6e4abf74 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -2288,6 +2288,15 @@ retry: unsigned bytes, sectors, offset_into_extent; enum btree_id data_btree = BTREE_ID_extents; + /* + * read_extent -> io_time_reset may cause a transaction restart + * without returning an error, we need to check for that here: + */ + if (!bch2_trans_relock(&trans)) { + ret = -EINTR; + break; + } + bch2_btree_iter_set_pos(iter, POS(inode, bvec_iter.bi_sector));