From: yangerkun <yangerkun@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <miaoxie@huawei.com>, <houtao1@huawei.com>, <yi.zhang@huawei.com>,
<yangerkun@huawei.com>
Subject: [PATCH 4/4] ext4: add mask of ext4 flags to swap
Date: Thu, 10 Jan 2019 11:36:50 +0800 [thread overview]
Message-ID: <20190110033650.108403-5-yangerkun@huawei.com> (raw)
In-Reply-To: <20190110033650.108403-1-yangerkun@huawei.com>
Not all flags should be swap, add a mask to do this.
Signed-off-by: yangerkun <yangerkun@huawei.com>
---
fs/ext4/ext4.h | 4 ++++
fs/ext4/ioctl.c | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 3f89d0a..b438a7c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -426,6 +426,10 @@ struct flex_groups {
/* Flags that are appropriate for non-directories/regular files. */
#define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL)
+/* Flags that should be swap */
+#define EXT4_FL_SHOULD_SWAP (EXT4_COMPR_FL | EXT4_COMPRBLK_FL | EXT4_NOCOMPR_FL |\
+ EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL)
+
/* Mask out flags that are inappropriate for the given type of inode. */
static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
{
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 60d406f..53e26a6 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -66,6 +66,7 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
struct inode *big_inode;
struct inode *small_inode;
qsize_t size1, size2, diff;
+ unsigned long tmp;
ei1 = EXT4_I(inode1);
ei2 = EXT4_I(inode2);
@@ -75,7 +76,10 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
swap(inode1->i_mtime, inode2->i_mtime);
memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data));
- swap(ei1->i_flags, ei2->i_flags);
+ tmp = ei1->i_flags & EXT4_FL_SHOULD_SWAP;
+ ei1->i_flags = (ei2->i_flags & EXT4_FL_SHOULD_SWAP) |
+ (ei1->i_flags & ~EXT4_FL_SHOULD_SWAP);
+ ei2->i_flags = tmp | (ei2->i_flags & ~EXT4_FL_SHOULD_SWAP);
swap(ei1->i_disksize, ei2->i_disksize);
ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
--
2.9.5
prev parent reply other threads:[~2019-01-10 3:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 3:36 [PATCH 0/4] fix bugs for ioctl EXT4_IOC_SWAP_BOOT yangerkun
2019-01-10 3:36 ` [PATCH 1/4] ext4: fix check of inode in swap_inode_boot_loader yangerkun
2019-01-10 3:36 ` [PATCH 2/4] ext4: cleanup pagecache before swap i_data yangerkun
2019-01-10 3:36 ` [PATCH 3/4] ext4: update quota information while swapping boot loader inode yangerkun
2019-01-10 3:36 ` yangerkun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190110033650.108403-5-yangerkun@huawei.com \
--to=yangerkun@huawei.com \
--cc=houtao1@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).