[Devel] [PATCH RHEL7 COMMIT] ploop: Change type of freezing argument on snapshot
Vasily Averin
vvs at virtuozzo.com
Fri Oct 2 13:10:04 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.31
------>
commit e31114211ecd7c1a75fe7dc4e8dbbfdf96615db3
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Oct 2 13:10:04 2020 +0300
ploop: Change type of freezing argument on snapshot
This interface is currently unused, so we can change it.
Before become to use it, Igor requested a possibility
to pass partition/block device/crypto target instead
of mount point.
This patch changes the type of argument: now open
block device fd is required. Also added sanity check
of sync_fd: in case of passed sync_fd == -1, we don't
differ it with the case when it is not passed at all.
https://jira.sw.ru/browse/PSBM-107925
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/block/ploop/dev.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 81340f9..d6edbfb 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -3680,20 +3680,23 @@ static int get_bdev_from_fd(int fd, struct block_device **bdev)
{
struct file *file = fget(fd);
struct inode *inode;
- int ret = -ENODEV;
+ int ret;
if (!file)
- return -ENODEV;
+ return -EBADF;
- inode = file_inode(file);
+ ret = -ENODEV;
+ inode = file->f_mapping->host;
if (!inode)
goto fput;
- *bdev = inode->i_sb->s_bdev;
- if (*bdev) {
- bdgrab(*bdev);
- ret = 0;
- }
+ ret = -ENOTBLK;
+ if (!S_ISBLK(inode->i_mode))
+ goto fput;
+
+ ret = 0;
+ *bdev = I_BDEV(inode);
+ bdgrab(*bdev);
fput:
fput(file);
return ret;
@@ -3780,6 +3783,8 @@ static int ploop_snapshot(struct ploop_device * plo, unsigned long arg,
return -EINVAL;
/* The rest of fields are ignored */
sync_fd = chunk.pctl_fd;
+ if (sync_fd < 0)
+ return -EBADF;
ctl.pctl_chunks = 1;
}
if (ctl.pctl_chunks != 1)
More information about the Devel
mailing list