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 <ktk...@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 4c4a0c6a908c..be74b2ec344f 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 8f5fb6d99d5e..67a385e9f716 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 @@ static int ext4_fastmap(struct inode *inode, sector_t 
lblk_sec,
 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 bed910acb39c..92543a9afe88 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)


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to