From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH v2 3/4] btrfs-progs: convert: Convert ext inode flags to btrfs inode flags
Date: Tue, 11 Oct 2016 10:44:45 +0800 [thread overview]
Message-ID: <20161011024446.16546-4-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <20161011024446.16546-1-quwenruo@cn.fujitsu.com>
Before this patch, btrfs-convert never copy ext* inode flags to
corresponding btrfs inode flags.
This makes common flags like APPEND/SYNC/SYNCDIR/IMMUTABLE not copied to
btrfs inode.
This patch introduces ext2_convert_inode_flags() function to handle the
convert, so btrfs-convert can copy as many inode flags as possible.
Reported-by: Lakshmipathi.G <lakshmipathi.g@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
btrfs-convert.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 542179e..2bcc16c 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2201,6 +2201,31 @@ static int ext2_check_state(struct btrfs_convert_context *cctx)
return 0;
}
+/* EXT2_*_FL to BTRFS_INODE_FLAG_* stringification helper */
+#define COPY_ONE_EXT2_FLAG(flags, ext2_inode, name) ({ \
+ if (ext2_inode->i_flags & EXT2_##name##_FL) \
+ flags |= BTRFS_INODE_##name; \
+})
+
+/*
+ * Convert EXT2_*_FL to corresponding BTRFS_INODE_* flags
+ *
+ * Only a subset of EXT_*_FL is supported in btrfs.
+ */
+static void ext2_convert_inode_flags(struct btrfs_inode_item *dst,
+ struct ext2_inode *src)
+{
+ u64 flags = 0;
+
+ COPY_ONE_EXT2_FLAG(flags, src, APPEND);
+ COPY_ONE_EXT2_FLAG(flags, src, SYNC);
+ COPY_ONE_EXT2_FLAG(flags, src, IMMUTABLE);
+ COPY_ONE_EXT2_FLAG(flags, src, NODUMP);
+ COPY_ONE_EXT2_FLAG(flags, src, NOATIME);
+ COPY_ONE_EXT2_FLAG(flags, src, DIRSYNC);
+ btrfs_set_stack_inode_flags(dst, flags);
+}
+
/*
* copy a single inode. do all the required works, such as cloning
* inode item, creating file extents and creating directory entries.
@@ -2223,6 +2248,7 @@ static int ext2_copy_single_inode(struct btrfs_trans_handle *trans,
BTRFS_INODE_NODATASUM;
btrfs_set_stack_inode_flags(&btrfs_inode, flags);
}
+ ext2_convert_inode_flags(&btrfs_inode, ext2_inode);
switch (ext2_inode->i_mode & S_IFMT) {
case S_IFREG:
--
2.10.0
next prev parent reply other threads:[~2016-10-11 2:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 2:44 [PATCH v2 0/4] Btrfs-convert: Add support to copy common inode flags Qu Wenruo
2016-10-11 2:44 ` [PATCH v2 1/4] btrfs-progs: Copy btrfs inode flags from kernel header Qu Wenruo
2016-10-11 2:44 ` [PATCH v2 2/4] btrfs-progs: Make btrfs-debug-tree print all readable strings for inode flags Qu Wenruo
2016-10-11 2:44 ` Qu Wenruo [this message]
2016-10-11 2:44 ` [PATCH v2 4/4] btrfs-progs: convert-test: Add test case for common " Qu Wenruo
[not found] ` <20161013141558.GW11398@twin.jikos.cz>
2016-10-14 0:50 ` [PATCH v2 0/4] Btrfs-convert: Add support to copy " Qu Wenruo
2016-10-14 14:57 ` David Sterba
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=20161011024446.16546-4-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/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).