[rh7,01/12] ploop: introduce dio_may_fallocate() helper

Submitted by Kirill Tkhai on March 1, 2019, 3:13 p.m.

Details

Message ID 155145320604.8852.10300925548326429750.stgit@localhost.localdomain
State New
Series "ploop: Add online discard support for dio engine"
Headers show

Commit Message

Kirill Tkhai March 1, 2019, 3:13 p.m.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/io_direct.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index dab0b1393cb8..f257a2770bcc 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -46,6 +46,12 @@  atomic_long_t ploop_io_images_size = ATOMIC_LONG_INIT(0);
  * Holes in image file are not allowed.
  */
 
+static bool dio_may_fallocate(struct ploop_io *io)
+{
+	return io->files.file->f_op->fallocate &&
+	       io->files.flags & EXT4_EXTENTS_FL;
+}
+
 static inline sector_t
 dio_isec_to_phys(struct extent_map * em, sector_t isec)
 {
@@ -354,8 +360,7 @@  cached_submit(struct ploop_io *io, iblock_t iblk, struct ploop_request * preq,
 	struct bio_iter biter;
 	loff_t new_size;
 	loff_t used_pos;
-	bool may_fallocate = io->files.file->f_op->fallocate &&
-		io->files.flags & EXT4_EXTENTS_FL;
+	bool may_fallocate = dio_may_fallocate(io);
 
 	trace_cached_submit(preq);