linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: linux-ext4@vger.kernel.org, "Theodore Ts'o" <tytso@mit.edu>,
	Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH v2 09/28] libext2fs: handle inline data in dir iterator function
Date: Tue, 3 Dec 2013 23:33:20 -0800	[thread overview]
Message-ID: <20131204073320.GR9535@birch.djwong.org> (raw)
In-Reply-To: <20131204062142.GB26103@gmail.com>

On Wed, Dec 04, 2013 at 02:21:42PM +0800, Zheng Liu wrote:
> On Tue, Dec 03, 2013 at 10:07:42PM -0800, Darrick J. Wong wrote:
> > On Wed, Dec 04, 2013 at 01:26:19PM +0800, Zheng Liu wrote:
> > > On Tue, Dec 03, 2013 at 09:10:25PM -0800, Darrick J. Wong wrote:
> > > > On Wed, Dec 04, 2013 at 12:57:36PM +0800, Zheng Liu wrote:
> > > > > On Tue, Dec 03, 2013 at 02:13:49PM -0800, Darrick J. Wong wrote:
> > > > > > On Tue, Dec 03, 2013 at 08:11:36PM +0800, Zheng Liu wrote:
> > > > > > > From: Zheng Liu <wenqing.lz@taobao.com>
> > > > > > > 
> > > > > > > Inline_data is handled in dir iterator because a lot of commands use
> > > > > > > this function to traverse directory entries in debugfs.  We need to
> > > > > > > handle inline_data individually because inline_data is saved in two
> > > > > > > places.  One is in i_block, and another is in ibody extended attribute.
> > > > > > > 
> > > > > > > After applied this commit, the following commands in debugfs can
> > > > > > > support the inline_data feature:
> > > > > > > 	- cd
> > > > > > > 	- chroot
> > > > > > > 	- link*
> > > > > > > 	- ls
> > > > > > > 	- ncheck
> > > > > > > 	- pwd
> > > > > > > 	- unlink
> > > > > > > 
> > > > > > > * TODO: Inline_data doesn't expand to ibody extended attribute because
> > > > > > >   link command doesn't handle DIR_NO_SPACE error until now.  But if we
> > > > > > >   have already expanded inline data to ibody ea area, link command can
> > > > > > >   occupy this space.
> > > > > > 
> > > > > > A patch for this TODO is coming, right?
> > > > > 
> > > > > TBH, I don't have a patch for this because I don't know why ext2fs_link
> > > > > doesn't handle DIR_NO_SPACE error.  So I will try to fix it later.
> > > > 
> > > > Yeah, it's sort of annoying that it doesn't do that.  You might notice that
> > > > fuse2fs will detect that error code, call ext2fs_expand_dir(), and try again.
> > > > On the other hand, none of the other programs do that...
> > > > 
> > > > ...it's not difficult to change ext2fs_link() to do that, though.
> > > > 
> > > > again:
> > > > 
> > > > /* link_proc magic... */
> > > > 
> > > > if (!ls.done && !not_again) {
> > > > 	ext2fs_expand_dir(fs, dir...);
> > > > 	not_again = 1;
> > > > 	goto again;
> > > > }
> > > > 
> > > > Hmm.  That /is/ easy to fix.  I might as well fix that.
> > > 
> > > I don't think we should fix it in ext2fs_link because I am afraid that
> > > we could break the client that has handled this problem.  So I am plan
> > > to fix it in make_link().  What do you think?
> > 
> > I think the clients will be fine.  Most likely, if the dir can't be expanded,
> > then ext2fs_link will return ext2fs_expand_directory's failure code.
> > 
> > On the off chance there's a weird bug somewhere such that we successfully
> > expand the dir but _link's built-in retry fails again, then the client will see
> > the "no dir space" error, expand the dir (again!), and retry the link, which
> > will again fail.  Assuming the client doesn't madly retry in a loop, all that
> > means is that we bang our heads against the wall a few more times than we need
> > to.
> > 
> > Luckily, most of the _link clients in the e2fsprogs source are too stupid even
> > to expand-and-retry.
> 
> OK.  So let me fix it. :)

Well, I need to fix up fuse2fs too anyway... something like this?

--D

diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c
index 09e6cb4..2cbf335 100644
--- a/lib/ext2fs/link.c
+++ b/lib/ext2fs/link.c
@@ -158,12 +158,14 @@ errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
 	errcode_t		retval;
 	struct link_struct	ls;
 	struct ext2_inode	inode;
+	int			tries = 0;
 
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
 	if (!(fs->flags & EXT2_FLAG_RW))
 		return EXT2_ET_RO_FILSYS;
 
+again:
 	ls.fs = fs;
 	ls.name = name;
 	ls.namelen = name ? strlen(name) : 0;
@@ -181,8 +183,16 @@ errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name,
 	if (ls.err)
 		return ls.err;
 
-	if (!ls.done)
-		return EXT2_ET_DIR_NO_SPACE;
+	/* If we didn't find space, expand the dir and try again */
+	if (!ls.done) {
+		if (tries)
+			return EXT2_ET_DIR_NO_SPACE;
+		retval = ext2fs_expand_dir(fs, dir);
+		if (retval)
+			return retval;
+		tries++;
+		goto again;
+	}
 
 	if ((retval = ext2fs_read_inode(fs, dir, &inode)) != 0)
 		return retval;

  reply	other threads:[~2013-12-04  7:33 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 12:11 [PATCH v2 00/28] e2fsprogs: inline data refinement patch set Zheng Liu
2013-12-03 12:11 ` [PATCH v2 01/28] libext2fs: support modifying arbitrary extended attributes Zheng Liu
2013-12-03 19:54   ` Darrick J. Wong
2013-12-04  3:20     ` Zheng Liu
2013-12-04  3:21       ` Darrick J. Wong
2013-12-04 14:53     ` Theodore Ts'o
2013-12-04 20:30       ` Darrick J. Wong
2013-12-04 22:43         ` Theodore Ts'o
2013-12-04 22:55           ` Darrick J. Wong
2013-12-03 12:11 ` [PATCH v2 02/28] libext2fs: various tweaks to the xattr editor APIs Zheng Liu
2013-12-03 12:11 ` [PATCH v2 03/28] libext2fs: extend xattr api to query number of attrs Zheng Liu
2013-12-03 12:11 ` [PATCH v2 04/28] libext2fs: fix memory leaks in extended attribute code Zheng Liu
2013-12-03 12:11 ` [PATCH v2 05/28] libext2fs: fix block leak when releasing xattr block Zheng Liu
2013-12-03 12:11 ` [PATCH v2 06/28] libext2fs: remove redundant code Zheng Liu
2013-12-03 12:11 ` [PATCH v2 07/28] libext2fs: free key/value pairs before reading Zheng Liu
2013-12-03 12:11 ` [PATCH v2 08/28] debugfs: dump all extended attributes Zheng Liu
2013-12-03 12:11 ` [PATCH v2 09/28] libext2fs: handle inline data in dir iterator function Zheng Liu
2013-12-03 22:13   ` Darrick J. Wong
2013-12-04  4:57     ` Zheng Liu
2013-12-04  5:10       ` Darrick J. Wong
2013-12-04  5:26         ` Zheng Liu
2013-12-04  6:07           ` Darrick J. Wong
2013-12-04  6:21             ` Zheng Liu
2013-12-04  7:33               ` Darrick J. Wong [this message]
2013-12-03 12:11 ` [PATCH v2 10/28] libext2fs: handle inline_data in block " Zheng Liu
2013-12-03 12:11 ` [PATCH v2 11/28] debugfs: make stat command support inline data Zheng Liu
2013-12-03 12:11 ` [PATCH v2 12/28] debugfs: make expand " Zheng Liu
2013-12-03 21:19   ` Darrick J. Wong
2013-12-04  3:42     ` Zheng Liu
2013-12-03 12:11 ` [PATCH v2 13/28] debugfs: make mkdir " Zheng Liu
2013-12-03 12:11 ` [PATCH v2 14/28] debugfs: make lsdel " Zheng Liu
2013-12-03 12:11 ` [PATCH v2 15/28] debugfs: handle inline_data feature in bmap command Zheng Liu
2013-12-04  3:11   ` Darrick J. Wong
2013-12-04  3:46     ` Zheng Liu
2013-12-03 12:11 ` [PATCH v2 16/28] debugfs: handle inline data feature in punch command Zheng Liu
2013-12-03 12:11 ` [PATCH v2 17/28] libext2fs: handle inline data in read/write function Zheng Liu
2013-12-04  3:02   ` Darrick J. Wong
2013-12-04  3:47     ` Zheng Liu
2013-12-03 12:11 ` [PATCH v2 18/28] libext2fs: add inline_data feature into EXT2_LIB_FEATURE_INCOMPAT_SUPP Zheng Liu
2013-12-03 12:11 ` [PATCH v2 19/28] mke2fs: add inline_data support in mke2fs Zheng Liu
2013-12-03 22:30   ` Darrick J. Wong
2013-12-04  3:27     ` Zheng Liu
2013-12-04  4:08       ` Darrick J. Wong
2013-12-04  5:21         ` Zheng Liu
2013-12-04  5:26           ` Darrick J. Wong
2013-12-04  5:50             ` Zheng Liu
2013-12-04  6:02               ` Darrick J. Wong
2013-12-04  6:18                 ` Zheng Liu
2013-12-03 12:11 ` [PATCH v2 20/28] tune2fs: add inline_data feature in tune2fs Zheng Liu
2013-12-03 22:29   ` Darrick J. Wong
2013-12-04  3:55     ` Zheng Liu
2013-12-04  4:03       ` Darrick J. Wong
2013-12-04  5:27         ` Zheng Liu
2013-12-03 12:11 ` [PATCH v2 21/28] e2fsck: add problem descriptions and check inline data feature Zheng Liu
2013-12-03 12:11 ` [PATCH v2 22/28] e2fsck: check inline_data in pass1 Zheng Liu
2013-12-03 12:11 ` [PATCH v2 23/28] e2fsck: check inline_data in pass2 Zheng Liu
2013-12-03 12:11 ` [PATCH v2 24/28] e2fsck: check inline_data in pass3 Zheng Liu
2013-12-03 12:11 ` [PATCH v2 25/28] tests: change result in f_bad_disconnected_inode Zheng Liu
2013-12-03 12:11 ` [PATCH v2 26/28] mke2fs: enable inline_data feature on ext4dev filesystem Zheng Liu
2013-12-03 12:11 ` [PATCH v2 27/28] libext2fs: export inode cahce creation function Zheng Liu
2013-12-03 22:22   ` Darrick J. Wong
2013-12-04  3:56     ` Zheng Liu
2013-12-03 12:11 ` [PATCH v2 28/28] 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=20131204073320.GR9535@birch.djwong.org \
    --to=darrick.wong@oracle.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).