From: Theodore Ts'o <tytso@mit.edu>
To: Darren Hart <dvhart@infradead.org>
Cc: linux-ext4@vger.kernel.org, adilger@dilger.ca,
sgw@linux.intel.com, darrick.wong@oracle.com
Subject: Re: [PATCH 1/3] lib/ext2fs: Add ext2fs_symlink
Date: Tue, 15 Jan 2013 14:43:30 -0500 [thread overview]
Message-ID: <20130115194330.GF17719@thunk.org> (raw)
In-Reply-To: <3fd850c4bf72f868b0d93bb0a5acced51fd25caa.1357329054.git.dvhart@infradead.org>
I'll fix up the this patch before I commit it, but this is a perfect
exhibit about why I request that code submissions come with test
cases. It turns out that there were a couple of problems with
ext2fs_symlink(), that showed up very quickly as soon as I started
writing a test case (where it's important to run e2fsck on the
resulting file system after creating the symlinks --- e2fsck is a
wonderful rep invariant checkers for ext[234] file systems. :-)
*) i_blocks must be set to 0 for fast symlinks
*) The last argument of ext2fs_inode_alloc_stats() indicates whether
the new inode is a directory or not. So when you cut and pasted
the code from ext2fs_mkdir(), it needed to be changed.
*) Zeroing the entire block before setting the symlink in the case
where it needs to use an external data block makes it a lot
easier to write the regression test.
So here's the patch I needed to apply on top of your submission....
- Ted
diff --git a/lib/ext2fs/symlink.c b/lib/ext2fs/symlink.c
index fb8b91b..da6e3a8 100644
--- a/lib/ext2fs/symlink.c
+++ b/lib/ext2fs/symlink.c
@@ -78,7 +78,7 @@ errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
memset(&inode, 0, sizeof(struct ext2_inode));
inode.i_mode = LINUX_S_IFLNK | 0777;
inode.i_uid = inode.i_gid = 0;
- ext2fs_iblk_set(fs, &inode, 1);
+ ext2fs_iblk_set(fs, &inode, fastlink ? 0 : 1);
inode.i_links_count = 1;
inode.i_size = target_len;
/* The time fields are set by ext2fs_write_new_inode() */
@@ -88,6 +88,7 @@ errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
strcpy((char *)&inode.i_block, target);
} else {
/* Slow symlinks, target stored in the first block */
+ memset(block_buf, 0, fs->blocksize);
strcpy(block_buf, target);
if (fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_EXTENTS) {
@@ -149,7 +150,7 @@ errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
*/
if (!fastlink)
ext2fs_block_alloc_stats2(fs, blk, +1);
- ext2fs_inode_alloc_stats2(fs, ino, +1, 1);
+ ext2fs_inode_alloc_stats2(fs, ino, +1, 0);
cleanup:
if (block_buf)
next prev parent reply other threads:[~2013-01-15 19:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-04 20:00 [PATCH 0/3 V2] ext2fsprogs: Symlink support Darren Hart
2013-01-04 20:00 ` [PATCH 1/3] lib/ext2fs: Add ext2fs_symlink Darren Hart
2013-01-04 20:00 ` [PATCH 2/3] debugfs: Add symlink command Darren Hart
2013-01-04 20:01 ` [PATCH 3/3] libext2fs: Remove obsolete redefinition of EXT2_FT_DIR Darren Hart
2013-01-05 20:07 ` [PATCH 1/3] lib/ext2fs: Add ext2fs_symlink Darrick J. Wong
2013-01-05 22:40 ` Theodore Ts'o
2013-01-15 19:17 ` Theodore Ts'o
2013-01-15 19:43 ` Theodore Ts'o [this message]
2013-01-15 19:53 ` [PATCH 1/2] debugfs: fix mknod command so that it updates the block group statistics Theodore Ts'o
2013-01-15 19:53 ` [PATCH 2/2] tests: create test for debugfs creating special files Theodore Ts'o
2013-01-19 5:29 ` [PATCH 1/3] lib/ext2fs: Add ext2fs_symlink Darren Hart
2013-01-05 0:15 ` [PATCH 0/3 V2] ext2fsprogs: Symlink support Theodore Ts'o
2013-01-05 0:26 ` Darren Hart
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=20130115194330.GF17719@thunk.org \
--to=tytso@mit.edu \
--cc=adilger@dilger.ca \
--cc=darrick.wong@oracle.com \
--cc=dvhart@infradead.org \
--cc=linux-ext4@vger.kernel.org \
--cc=sgw@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.