[Devel] [PATCH RHEL7 COMMIT] ploop: Add statistics of fastmap requests, which fails because of cache
Vasily Averin
vvs at virtuozzo.com
Tue Nov 10 13:43:43 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1160.2.2.vz7.170.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.2.2.el7
------>
commit 56a50079f0317675af4d9c1018f38b47ca2d476c
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Tue Nov 10 13:43:43 2020 +0300
ploop: Add statistics of fastmap requests, which fails because of cache
Normally, mapping_needs_writeback() should not be true. But in case
of some problem, or userspace touch root.hds without direct mode,
cache may populate. Count such the failed fastmaps.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/io_kaio.c | 2 ++
fs/ext4/file.c | 5 ++++-
include/linux/ploop/ploop_stat.h | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 4c4a0c6..be74b2e 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -1236,6 +1236,8 @@ kaio_fastmap(struct ploop_io *io, struct bio *orig_bio,
orig_bio->bi_rw & REQ_WRITE);
if (ret < 0) {
io->plo->st.fast_neg_noem++;
+ if (ret == -EBUSY)
+ io->plo->st.write_back_pending++;
return 1;
}
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 8f5fb6d..67a385e 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -132,6 +132,7 @@ static int ext4_fastmap(struct inode *inode, sector_t lblk_sec,
bool unaligned_aio, found, locked = false;
struct ext4_map_blocks map;
loff_t pos = lblk_sec << 9;
+ int err;
if (!S_ISREG(inode->i_mode))
return -ENOENT;
@@ -152,6 +153,7 @@ static int ext4_fastmap(struct inode *inode, sector_t lblk_sec,
locked = true;
}
+ err = -EBUSY;
if (unlikely(mapping_needs_writeback(mapping)))
goto err_maybe_unlock;
@@ -163,6 +165,7 @@ static int ext4_fastmap(struct inode *inode, sector_t lblk_sec,
locked = false;
}
+ err = -ENOENT;
if (unlikely(ext4_test_inode_state(inode,
EXT4_STATE_DIOREAD_LOCK))) {
goto err_dio_end;
@@ -181,7 +184,7 @@ err_dio_end:
err_maybe_unlock:
if (locked)
mutex_unlock(&inode->i_mutex);
- return -ENOENT;
+ return err;
}
static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *iter, loff_t *pos)
diff --git a/include/linux/ploop/ploop_stat.h b/include/linux/ploop/ploop_stat.h
index bed910a..92543a9 100644
--- a/include/linux/ploop/ploop_stat.h
+++ b/include/linux/ploop/ploop_stat.h
@@ -34,6 +34,7 @@ __DO(merge_neg_cluster)
__DO(merge_neg_disable)
__DO(fast_neg_nomap)
__DO(fast_neg_noem)
+__DO(write_back_pending)
__DO(fast_neg_shortem)
__DO(fast_neg_backing)
__DO(bio_lockouts)
More information about the Devel
mailing list