From: Jan Kara <jack@suse.cz>
To: Eric Sandeen <sandeen@redhat.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>,
Anand Avati <avati@redhat.com>, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH, RFC V3] ext3: add ioctl to force 32-bit hashes from indexed dirs
Date: Wed, 3 Apr 2013 14:54:19 +0200 [thread overview]
Message-ID: <20130403125419.GA14667@quack.suse.cz> (raw)
In-Reply-To: <5159A8D5.1000204@redhat.com>
On Mon 01-04-13 10:33:41, Eric Sandeen wrote:
> This adds a new ioctl, EXT3_IOC_32BITHASH, which allows a
> userspace application to request 32-bit rather than 64-bit
> hashes from readdir on an indexed / dx / htree directory.
>
> Gluster had been relying on the top bits of the d_off being
> free; there are some reports that filling all 64 bits breaks
> Samba as well. The infrastructure to return 32-bit hashes
> already exists; NFS can turn it on, and it's turned on for
> 32-bit processes as well. So it's just a matter of flipping
> on the f_mode flag before readdir starts.
>
> Care needs to be taken that we don't change the FMODE flag
> after readdir has been started, so we make sure that
> filp->private_data has not yet been set before we set the flag.
> (Thanks Zach!).
OK, I'm happy with this patch. So if Samba people confirm they are really
going to use it, I'll merge the patch.
Honza
> Pre-submission-fixes-by: Zach Brown <zab@redhat.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> V2:
> fix "readir" typo
> rename goto target to *_out like others
> remove parameter; we can't really ever turn this back off once it's used.
> closing and reopening is the only way to get back to 64 bit hashes.
>
> V3:
> return -ENOTDIR if the target is not a directory
>
>
>
>
> diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
> index 87eccbb..83df29f 100644
> --- a/fs/ext3/dir.c
> +++ b/fs/ext3/dir.c
> @@ -47,7 +47,7 @@ static unsigned char get_dtype(struct super_block *sb, int filetype)
> *
> * Return 1 if it is a dx dir, 0 if not
> */
> -static int is_dx_dir(struct inode *inode)
> +int is_dx_dir(struct inode *inode)
> {
> struct super_block *sb = inode->i_sb;
>
> diff --git a/fs/ext3/ext3.h b/fs/ext3/ext3.h
> index e85ff15..f3018f4 100644
> --- a/fs/ext3/ext3.h
> +++ b/fs/ext3/ext3.h
> @@ -220,6 +220,7 @@ struct ext3_new_group_data {
> #endif
> #define EXT3_IOC_GETRSVSZ _IOR('f', 5, long)
> #define EXT3_IOC_SETRSVSZ _IOW('f', 6, long)
> +#define EXT3_IOC_32BITHASH _IO('f', 13)
>
> /*
> * ioctl commands in 32 bit emulation
> @@ -1010,6 +1011,7 @@ extern void ext3_rsv_window_add(struct super_block *sb, struct ext3_reserve_wind
> extern int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range);
>
> /* dir.c */
> +extern int is_dx_dir(struct inode *inode);
> extern int ext3_check_dir_entry(const char *, struct inode *,
> struct ext3_dir_entry_2 *,
> struct buffer_head *, unsigned long);
> diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
> index 4d96e9a..a7d2b0a 100644
> --- a/fs/ext3/ioctl.c
> +++ b/fs/ext3/ioctl.c
> @@ -251,6 +251,39 @@ group_add_out:
> mnt_drop_write_file(filp);
> return err;
> }
> + case EXT3_IOC_32BITHASH: {
> + int err = 0;
> +
> + /* Serialize with readdir */
> + if ((err = mutex_lock_killable(&inode->i_mutex)))
> + return err;
> +
> + /* protect f_mode */
> + spin_lock(&filp->f_lock);
> +
> + /* Only valid for htree directories */
> + if (!S_ISDIR(inode->i_mode)) {
> + err = -ENOTDIR;
> + goto hash32bits_out;
> + }
> +
> + if (!is_dx_dir(inode)) {
> + err = -EINVAL;
> + goto hash32bits_out;
> + }
> +
> + /* Have we already started readdir on this dx dir? */
> + if (filp->private_data) {
> + err = -EINVAL;
> + goto hash32bits_out;
> + }
> +
> + filp->f_mode |= FMODE_32BITHASH;
> +hash32bits_out:
> + spin_unlock(&filp->f_lock);
> + mutex_unlock(&inode->i_mutex);
> + return err;
> + }
> case FITRIM: {
>
> struct super_block *sb = inode->i_sb;
>
>
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2013-04-03 12:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 16:25 [PATCH, RFC] ext3: add ioctl to force 32-bit hashes from indexed dirs Eric Sandeen
2013-03-28 20:40 ` [PATCH, RFC V2] " Eric Sandeen
2013-03-29 11:43 ` Jan Kara
2013-04-01 15:13 ` Eric Sandeen
2013-04-01 15:33 ` [PATCH, RFC V3] " Eric Sandeen
2013-04-01 18:17 ` Theodore Ts'o
2013-04-01 18:21 ` Eric Sandeen
2013-04-01 19:08 ` Theodore Ts'o
2013-04-01 19:49 ` Eric Sandeen
2013-04-01 20:00 ` Theodore Ts'o
2013-04-01 20:05 ` Eric Sandeen
2013-04-01 20:09 ` Theodore Ts'o
[not found] ` <5159E88F.8030704-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-04-01 20:34 ` Anand Avati
2013-04-05 23:05 ` Andrew Bartlett
2013-04-05 23:28 ` J. Bruce Fields
2013-04-05 23:26 ` Anand Avati
2013-04-08 9:28 ` Andrew Bartlett
2013-04-03 12:54 ` Jan Kara [this message]
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=20130403125419.GA14667@quack.suse.cz \
--to=jack@suse.cz \
--cc=avati@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sandeen@redhat.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).