diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-23 23:10:20 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-30 12:30:49 -0500 |
commit | ed0bf94281867497c0e088451e4edc1fd517209f (patch) | |
tree | 9bf427670ce7ebc948da37f277468b5775c3e2df | |
parent | 36d356e3898a3393a42e4704c5d2a942b230dbe9 (diff) |
bcachefs: Optimize cacheline access in __bch2_write()
This tweaks __bch2_write() to add the bch_write_op to the writepoint
list before submitting the bio - we prefer to not have to touch the op
at all after submitting the bio, and before submitting the bio the
writepoint is still in cache.
Also, this centralizes where we set BCH_WRITE_DONE, making for a minor
cleanup.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/io.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 25534a113b7b..e40d196edb58 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -1620,27 +1620,33 @@ again: BCH_WRITE_ONLY_SPECIFIED_DEVS)) ? NULL : &op->cl, &wp)); if (unlikely(ret)) { - if (unlikely(ret != -EAGAIN)) { - op->error = ret; - op->flags |= BCH_WRITE_DONE; - } + if (ret == -EAGAIN) + break; - break; + goto err; } - bch2_open_bucket_get(c, wp, &op->open_buckets); ret = bch2_write_extent(op, wp, &bio); + if (ret >= 0) + bch2_open_bucket_get(c, wp, &op->open_buckets); bch2_alloc_sectors_done_inlined(c, wp); +err: + if (ret <= 0) { + if (!(op->flags & BCH_WRITE_SYNC)) { + spin_lock(&wp->writes_lock); + op->wp = wp; + list_add_tail(&op->wp_list, &wp->writes); + spin_unlock(&wp->writes_lock); + } - if (ret < 0) { - op->error = ret; op->flags |= BCH_WRITE_DONE; - break; - } - if (!ret) - op->flags |= BCH_WRITE_DONE; + if (ret < 0) { + op->error = ret; + break; + } + } bio->bi_end_io = bch2_write_endio; bio->bi_private = &op->cl; @@ -1670,11 +1676,6 @@ again: goto again; bch2_write_done(&op->cl); } else { - spin_lock(&wp->writes_lock); - op->wp = wp; - list_add_tail(&op->wp_list, &wp->writes); - spin_unlock(&wp->writes_lock); - continue_at(&op->cl, bch2_write_index, NULL); } out_nofs_restore: |