[Devel] [PATCH VZ9] dm-qcow2 check if files are opened with O_DIRECT
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Tue Sep 20 11:23:28 MSK 2022
Check that passed file descriptors are using O_DIRECT.
Required to avoid data integrity problems caused by
the page cache.
https://jira.sw.ru/browse/PSBM-142050
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/md/dm-qcow2-target.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 9a6f970343ec..995679b3cd98 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -678,6 +678,9 @@ static int qcow2_attach_file(struct dm_target *ti, struct qcow2_target *tgt,
if (!S_ISREG(file_inode(file)->i_mode))
return -EINVAL;
+ if (!(file->f_flags & O_DIRECT))
+ return -EINVAL;
+
mode = tgt->top != qcow2 ? FMODE_READ : dm_table_get_mode(ti->table);
mode &= (FMODE_READ|FMODE_WRITE);
if (mode & ~(file->f_mode & (FMODE_READ|FMODE_WRITE)))
--
2.31.1
More information about the Devel
mailing list