From: "Darrick J. Wong" <djwong@us.ibm.com>
To: "Ted Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] libext2fs: Only link an inode into a directory once
Date: Wed, 15 Feb 2012 12:40:15 -0800 [thread overview]
Message-ID: <20120215204015.GB15164@tux1.beaverton.ibm.com> (raw)
In-Reply-To: <20120215192537.GI11382@thunk.org>
On Wed, Feb 15, 2012 at 02:25:37PM -0500, Ted Ts'o wrote:
> On Fri, Jan 06, 2012 at 08:47:43PM -0800, Darrick J. Wong wrote:
> > The ext2fs_link helper function link_proc does not check the value of ls->done,
> > which means that if the function finds multiple empty spaces that will fit the
> > new directory entry, it will create a directory entry in each of the spaces.
> > Instead of doing that, check the done value and don't do anything more if we've
> > already added the directory entry.
> >
> > Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
>
> This should't necessary, since when we insert the directory entry, we
> return with the DIRENT_ABORT bit set:
>
> dirent->inode = ls->inode;
> dirent->name_len = ls->namelen;
> strncpy(dirent->name, ls->name, ls->namelen);
> if (ls->sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE)
> dirent->name_len |= (ls->flags & 0x7) << 8;
>
> ls->done++;
> return DIRENT_ABORT|DIRENT_CHANGED;
>
> Did you actually observe this happening?
Yes. I took a look at the block iteration code again, and I'm wondering, do we
need one of these:
if (ret & BLOCK_ABORT)
break;
...around lib/ext2fs/block.c, line 450? This is the code blob:
if (!(extent.e_flags & EXT2_EXTENT_FLAGS_LEAF)) {
if (ctx.flags & BLOCK_FLAG_DATA_ONLY)
continue;
if ((!(extent.e_flags &
EXT2_EXTENT_FLAGS_SECOND_VISIT) &&
!(ctx.flags & BLOCK_FLAG_DEPTH_TRAVERSE)) ||
((extent.e_flags &
EXT2_EXTENT_FLAGS_SECOND_VISIT) &&
(ctx.flags & BLOCK_FLAG_DEPTH_TRAVERSE))) {
ret |= (*ctx.func)(fs, &blk,
-1, 0, 0, priv_data);
if (ret & BLOCK_CHANGED) {
extent.e_pblk = blk;
ctx.errcode =
ext2fs_extent_replace(handle, 0, &extent);
if (ctx.errcode)
break;
}
/* INSERT HERE? */
}
continue;
}
It looks to me that when ctx.func returns BLOCK_ABORT, the continue causes
the code to loop around and get the next extent, which isn't what we want.
--D
next prev parent reply other threads:[~2012-02-15 20:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-07 4:47 [PATCH] libext2fs: Only link an inode into a directory once Darrick J. Wong
2012-02-15 19:25 ` Ted Ts'o
2012-02-15 20:40 ` Darrick J. Wong [this message]
2012-02-15 22:23 ` Ted Ts'o
2012-02-15 22:27 ` [PATCH] libext2fs: fix BLOCK_ABORT handling in the block iterator for extents Theodore Ts'o
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=20120215204015.GB15164@tux1.beaverton.ibm.com \
--to=djwong@us.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).