]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: cleanup the VM accounting in submit_bio
authorChristoph Hellwig <hch@lst.de>
Mon, 16 May 2022 06:36:54 +0000 (08:36 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 16 May 2022 17:37:50 +0000 (11:37 -0600)
submit_bio uses some extremely convoluted checks and confusing comments
to only account REQ_OP_READ/REQ_OP_WRITE comments.  Just switch to the
plain obvious checks instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220516063654.2782792-1-hch@lst.de
[axboe: fixup WRITE -> REQ_OP_WRITE]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c

index c3f1e46ddd433743ac387892c6c7b230d7bf177e..23312df7d25d0ca99a55ee7ddfc467fe615eb251 100644 (file)
@@ -892,19 +892,11 @@ void submit_bio(struct bio *bio)
        if (blkcg_punt_bio_submit(bio))
                return;
 
-       /*
-        * If it's a regular read/write or a barrier with data attached,
-        * go through the normal accounting stuff before submission.
-        */
-       if (bio_has_data(bio)) {
-               unsigned int count = bio_sectors(bio);
-
-               if (op_is_write(bio_op(bio))) {
-                       count_vm_events(PGPGOUT, count);
-               } else {
-                       task_io_account_read(bio->bi_iter.bi_size);
-                       count_vm_events(PGPGIN, count);
-               }
+       if (bio_op(bio) == REQ_OP_READ) {
+               task_io_account_read(bio->bi_iter.bi_size);
+               count_vm_events(PGPGIN, bio_sectors(bio));
+       } else if (bio_op(bio) == REQ_OP_WRITE) {
+               count_vm_events(PGPGOUT, bio_sectors(bio));
        }
 
        /*