[Devel] [PATCH RHEL7 COMMIT] ext4: Add ioctl EXT4_IOC_SET_RSV_BLOCKS V2
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Jun 22 03:38:39 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.15
------>
commit d7f53fb77a6fe22a6383a530e2f4bf12b1cc486b
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date: Mon Jun 22 14:38:38 2015 +0400
ext4: Add ioctl EXT4_IOC_SET_RSV_BLOCKS V2
We have to update reservation block counts according to balloon size.
One can do that directly via tune2fs which is not good for mounted fs,
and should use this ioctl instead.
changes from v1:
- add missed ext4_handle_dirty_metadata
- change error code
https://jira.sw.ru/browse/PSBM-25929
Orig-patch:diff-ext4-add-ioctl-EXT4_IOC_SET_RSV_BLOCKS-v2
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
fs/ext4/ext4.h | 1 +
fs/ext4/ioctl.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index a4c98cc..e53ceed 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -621,6 +621,7 @@ enum {
#define EXT4_IOC_SWAP_BOOT _IO('f', 17)
#define EXT4_IOC_OPEN_BALLOON _IO('f', 42)
#define EXT4_IOC_MFSYNC _IO('f', 43)
+#define EXT4_IOC_SET_RSV_BLOCKS _IOW('f', 44, __u64)
#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
/*
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 597ab44..fc18911 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -648,6 +648,66 @@ resizefs_out:
ext4_resize_end(sb);
return err;
}
+ case EXT4_IOC_SET_RSV_BLOCKS: {
+ ext4_fsblk_t n_blocks_count;
+ struct super_block *sb = inode->i_sb;
+ handle_t *handle;
+ int err = 0, err2 = 0;
+
+ if (copy_from_user(&n_blocks_count, (__u64 __user *)arg,
+ sizeof(__u64))) {
+ return -EFAULT;
+ }
+
+ if (n_blocks_count > MAX_32_NUM &&
+ !EXT4_HAS_INCOMPAT_FEATURE(sb,
+ EXT4_FEATURE_INCOMPAT_64BIT)) {
+ ext4_msg(sb, KERN_ERR,
+ "File system only supports 32-bit block numbers");
+ return -EOPNOTSUPP;
+ }
+
+ if (n_blocks_count > ext4_blocks_count(EXT4_SB(sb)->s_es))
+ return -EINVAL;
+
+ err = ext4_resize_begin(sb);
+ if (err)
+ return err;
+
+ err = mnt_want_write(filp->f_path.mnt);
+ if (err)
+ goto resize_out;
+
+ handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);
+ if (IS_ERR(handle)) {
+ err = PTR_ERR(handle);
+ goto mnt_out;
+ }
+ err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
+ if (err) {
+ goto journal_out;
+ }
+ ext4_r_blocks_count_set(EXT4_SB(sb)->s_es, n_blocks_count);
+ ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
+journal_out:
+ err2 = ext4_journal_stop(handle);
+ if (err == 0)
+ err = err2;
+
+ if (!err && EXT4_SB(sb)->s_journal) {
+ jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
+ err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal);
+ jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
+ }
+ if (err == 0)
+ err = err2;
+mnt_out:
+ mnt_drop_write(filp->f_path.mnt);
+resize_out:
+ ext4_resize_end(sb);
+ return err;
+ }
+
case FITRIM:
{
More information about the Devel
mailing list