From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Zheng Liu <gnehzuil.liu@gmail.com>
Cc: linux-ext4@vger.kernel.org, "Theodore Ts'o" <tytso@mit.edu>,
Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH v1 17/22] e2fsck: check inline_data in pass1
Date: Fri, 11 Oct 2013 17:47:09 -0700 [thread overview]
Message-ID: <20131012004709.GX6860@birch.djwong.org> (raw)
In-Reply-To: <1375436989-18948-18-git-send-email-wenqing.lz@taobao.com>
On Fri, Aug 02, 2013 at 05:49:44PM +0800, Zheng Liu wrote:
> From: Zheng Liu <wenqing.lz@taobao.com>
>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
> ---
> e2fsck/pass1.c | 70 ++++++++++++++++++++++++++++++++++++++++++++---
> lib/ext2fs/dblist_dir.c | 10 +++++--
> 2 files changed, 74 insertions(+), 6 deletions(-)
>
> diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
> index e6ea460..4301bb9 100644
> --- a/e2fsck/pass1.c
> +++ b/e2fsck/pass1.c
> @@ -202,6 +202,16 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
> return i;
> }
>
> + if (inode->i_flags & EXT4_INLINE_DATA_FL) {
> + unsigned int inline_size;
> +
> + inline_size = ext2fs_inline_data_get_size(fs, ino);
> + if (inline_size == inode->i_size)
> + return 1;
> + else
> + return 0;
> + }
> +
> blocks = ext2fs_inode_data_blocks2(fs, inode);
> if (blocks) {
> if ((inode->i_size >= fs->blocksize) ||
> @@ -303,6 +313,15 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
> goto fix;
> }
>
> + /*
> + * Don't do the following checks for inline_data because
> + * other checks ensure the content of inline data right.
> + */
> + if (strncmp(EXT2_EXT_ATTR_NAME(entry),
> + EXT4_EXT_ATTR_SYSTEM_DATA,
> + strlen(EXT4_EXT_ATTR_SYSTEM_DATA)) == 0)
Please align arguments 2 and 3 with argument 1 of strcmp.
--D
> + goto next;
> +
> /* attribute len eats this space */
> remain -= EXT2_EXT_ATTR_SIZE(entry->e_name_len);
>
> @@ -330,6 +349,7 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
> goto fix;
> }
>
> +next:
> remain -= entry->e_value_size;
>
> entry = EXT2_EXT_ATTR_NEXT(entry);
> @@ -407,6 +427,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
> blk64_t blk;
> unsigned int i, rec_len, not_device = 0;
> int extent_fs;
> + int inlinedata_fs;
>
> /*
> * If the mode looks OK, we believe it. If the first block in
> @@ -434,11 +455,19 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
> * For extent mapped files, we don't do any sanity checking:
> * just try to get the phys block of logical block 0 and run
> * with it.
> + *
> + * For inline_data files, we just skip it because, in e2fsck
> + * pass1, we cannot get parent inode of a inode. So we have
> + * no way to determine the inode is a directory or not.
> */
>
> extent_fs = (ctx->fs->super->s_feature_incompat &
> EXT3_FEATURE_INCOMPAT_EXTENTS);
> - if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) {
> + inlinedata_fs = (ctx->fs->super->s_feature_incompat &
> + EXT4_FEATURE_INCOMPAT_INLINE_DATA);
> + if (inlinedata_fs && (inode->i_flags & EXT4_INLINE_DATA_FL))
> + return;
> + else if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) {
> /* extent mapped */
> if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0,
> &blk))
> @@ -1205,7 +1234,8 @@ void e2fsck_pass1(e2fsck_t ctx)
> ctx->fs_sockets_count++;
> } else
> mark_inode_bad(ctx, ino);
> - if (!(inode->i_flags & EXT4_EXTENTS_FL)) {
> + if (!(inode->i_flags & EXT4_EXTENTS_FL) &&
> + !(inode->i_flags & EXT4_INLINE_DATA_FL)) {
> if (inode->i_block[EXT2_IND_BLOCK])
> ctx->fs_ind_count++;
> if (inode->i_block[EXT2_DIND_BLOCK])
> @@ -1214,6 +1244,7 @@ void e2fsck_pass1(e2fsck_t ctx)
> ctx->fs_tind_count++;
> }
> if (!(inode->i_flags & EXT4_EXTENTS_FL) &&
> + !(inode->i_flags & EXT4_INLINE_DATA_FL) &&
> (inode->i_block[EXT2_IND_BLOCK] ||
> inode->i_block[EXT2_DIND_BLOCK] ||
> inode->i_block[EXT2_TIND_BLOCK] ||
> @@ -2129,6 +2160,28 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
> }
>
> /*
> + * In fact we needn't check blocks for a inode that has inline data because
> + * this inode doesn't have any blocks. In this function, all we need to do
> + * is add this inode into dblist when it is a directory.
> + */
> +static void check_blocks_inline_data(e2fsck_t ctx,
> + struct problem_context *pctx,
> + struct process_block_struct *pb)
> +{
> + if (!pb->is_dir)
> + return;
> +
> + pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist,
> + pb->ino, 0, 0);
> + if (pctx->errcode) {
> + pctx->blk = 0;
> + pctx->num = 0;
> + fix_problem(ctx, PR_1_ADD_DBLOCK, pctx);
> + ctx->flags |= E2F_FLAG_ABORT;
> + }
> +}
> +
> +/*
> * This subroutine is called on each inode to account for all of the
> * blocks used by that inode.
> */
> @@ -2142,6 +2195,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
> int bad_size = 0;
> int dirty_inode = 0;
> int extent_fs;
> + int inlinedata_fs;
> __u64 size;
>
> pb.ino = ino;
> @@ -2165,6 +2219,8 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
>
> extent_fs = (ctx->fs->super->s_feature_incompat &
> EXT3_FEATURE_INCOMPAT_EXTENTS);
> + inlinedata_fs = (ctx->fs->super->s_feature_incompat &
> + EXT4_FEATURE_INCOMPAT_INLINE_DATA);
>
> if (inode->i_flags & EXT2_COMPRBLK_FL) {
> if (fs->super->s_feature_incompat &
> @@ -2188,6 +2244,9 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
> if (ext2fs_inode_has_valid_blocks2(fs, inode)) {
> if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL))
> check_blocks_extents(ctx, pctx, &pb);
> + else if (inlinedata_fs &&
> + (inode->i_flags & EXT4_INLINE_DATA_FL))
> + check_blocks_inline_data(ctx, pctx, &pb);
> else {
> pctx->errcode = ext2fs_block_iterate3(fs, ino,
> pb.is_dir ? BLOCK_FLAG_HOLE : 0,
> @@ -2230,7 +2289,8 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
> }
> }
>
> - if (!pb.num_blocks && pb.is_dir) {
> + if (!pb.num_blocks && pb.is_dir &&
> + !(inode->i_flags & EXT4_INLINE_DATA_FL)) {
> if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) {
> e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks");
> ctx->fs_directory_count--;
> @@ -2256,7 +2316,9 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
> #endif
> if (pb.is_dir) {
> int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
> - if (inode->i_size & (fs->blocksize - 1))
> + if (inode->i_flags & EXT4_INLINE_DATA_FL)
> + ;
> + else if (inode->i_size & (fs->blocksize - 1))
> bad_size = 5;
> else if (nblock > (pb.last_block + 1))
> bad_size = 1;
> diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c
> index d4d5111..6282ab4 100644
> --- a/lib/ext2fs/dblist_dir.c
> +++ b/lib/ext2fs/dblist_dir.c
> @@ -72,8 +72,14 @@ static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry2 *db_info,
> ctx->dir = db_info->ino;
> ctx->errcode = 0;
>
> - ret = ext2fs_process_dir_block(fs, &db_info->blk,
> - db_info->blockcnt, 0, 0, priv_data);
> + if (ext2fs_inode_has_inline_data(fs, ctx->dir))
> + ret = ext2fs_inline_data_iterate(fs, ctx->dir, 0, 0,
> + ext2fs_process_dir_inline_data,
> + priv_data);
> + else
> + ret = ext2fs_process_dir_block(fs, &db_info->blk,
> + db_info->blockcnt,
> + 0, 0, priv_data);
> if ((ret & BLOCK_ABORT) && !ctx->errcode)
> return DBLIST_ABORT;
> return 0;
> --
> 1.7.9.7
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-10-12 0:47 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-02 9:49 [PATCH v1 00/22] e2fsprogs: inline data refinement patch set Zheng Liu
2013-08-02 9:49 ` [PATCH v1 01/22] libext2fs: add INLINE_DATA into EXT2_LIB_SOFTSUPP_INCOMPAT Zheng Liu
2013-10-13 3:21 ` Theodore Ts'o
2013-08-02 9:49 ` [PATCH v1 02/22] libext2fs: add function to check inline_data flag for an inode Zheng Liu
2013-08-02 9:49 ` [PATCH v1 03/22] libext2fs: add functions to operate on extended attribute Zheng Liu
2013-08-05 17:34 ` Darrick J. Wong
2013-08-05 23:14 ` Zheng Liu
2013-10-14 1:55 ` Theodore Ts'o
2013-10-14 2:41 ` Zheng Liu
2013-10-11 22:51 ` Darrick J. Wong
2013-10-12 5:51 ` Zheng Liu
2013-10-12 8:32 ` Darrick J. Wong
2013-10-12 8:41 ` Zheng Liu
2013-10-12 9:02 ` Darrick J. Wong
2013-10-12 9:08 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 04/22] libext2fs: handle inline data in dir iterator function Zheng Liu
2013-10-11 23:33 ` Darrick J. Wong
2013-10-12 5:55 ` Zheng Liu
2013-10-13 22:51 ` Theodore Ts'o
2013-10-14 3:07 ` Zheng Liu
2013-10-14 1:58 ` Theodore Ts'o
2013-08-02 9:49 ` [PATCH v1 05/22] libext2fs: handle inline_data in block " Zheng Liu
2013-10-13 3:55 ` Theodore Ts'o
2013-10-14 0:44 ` Theodore Ts'o
2013-10-14 2:49 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 06/22] debugfs: make stat command support inline data Zheng Liu
2013-10-11 23:43 ` Darrick J. Wong
2013-10-12 0:07 ` Darrick J. Wong
2013-08-02 9:49 ` [PATCH v1 07/22] debugfs: make mkdir and expanddir " Zheng Liu
2013-10-12 0:21 ` Darrick J. Wong
2013-10-12 7:15 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 08/22] debugfs: make lsdel " Zheng Liu
2013-08-02 9:49 ` [PATCH v1 09/22] libext2fs: handle inline data in read/write function Zheng Liu
2013-08-02 9:49 ` [PATCH v1 10/22] debugfs: handle inline_data feature in dirsearch command Zheng Liu
2013-10-12 0:30 ` Darrick J. Wong
2013-10-12 7:21 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 11/22] debugfs: handle inline_data feature in bmap command Zheng Liu
2013-08-02 9:49 ` [PATCH v1 12/22] debugfs: handle inline_data in punch command Zheng Liu
2013-10-12 0:37 ` Darrick J. Wong
2013-10-12 7:22 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 13/22] libext2fs: add inline_data feature into EXT2_LIB_FEATURE_INCOMPAT_SUPP Zheng Liu
2013-08-02 9:49 ` [PATCH v1 14/22] mke2fs: add inline_data support in mke2fs Zheng Liu
2013-10-12 0:27 ` Darrick J. Wong
2013-10-12 8:08 ` Zheng Liu
2013-10-12 8:18 ` Darrick J. Wong
2013-10-12 8:31 ` Zheng Liu
2013-10-12 8:32 ` Darrick J. Wong
2013-08-02 9:49 ` [PATCH v1 15/22] tune2fs: add inline_data feature in tune2fs Zheng Liu
2013-10-12 0:39 ` Darrick J. Wong
2013-10-12 8:16 ` Zheng Liu
2013-10-12 8:23 ` Darrick J. Wong
2013-10-12 8:33 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 16/22] e2fsck: add problem descriptions and check inline data feature Zheng Liu
2013-08-02 9:49 ` [PATCH v1 17/22] e2fsck: check inline_data in pass1 Zheng Liu
2013-10-12 0:47 ` Darrick J. Wong [this message]
2013-10-12 8:17 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 18/22] e2fsck: check inline_data in pass2 Zheng Liu
2013-08-02 9:49 ` [PATCH v1 19/22] e2fsck: check inline_data in pass3 Zheng Liu
2013-10-12 0:54 ` Darrick J. Wong
2013-10-12 9:06 ` Zheng Liu
2013-10-12 9:09 ` Darrick J. Wong
2013-10-12 9:17 ` Zheng Liu
2013-10-12 9:22 ` Darrick J. Wong
2013-10-12 9:32 ` Zheng Liu
2013-08-02 9:49 ` [PATCH v1 20/22] tests: change result in f_bad_disconnected_inode Zheng Liu
2013-08-02 9:49 ` [PATCH v1 21/22] mke2fs: enable inline_data feature on ext4dev filesystem Zheng Liu
2013-08-02 9:49 ` [PATCH v1 22/22] libext2fs: add a unit test for inline data Zheng Liu
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=20131012004709.GX6860@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=gnehzuil.liu@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=wenqing.lz@taobao.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).