From patchwork Thu Mar 28 16:25:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 232095 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 072AF2C007C for ; Fri, 29 Mar 2013 03:26:04 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754983Ab3C1Q0D (ORCPT ); Thu, 28 Mar 2013 12:26:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33548 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753268Ab3C1Q0C (ORCPT ); Thu, 28 Mar 2013 12:26:02 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2SGPJ57004090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Mar 2013 12:25:19 -0400 Received: from liberator.sandeen.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2SGPHBN011471 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 28 Mar 2013 12:25:18 -0400 Message-ID: <51546EED.8030507@redhat.com> Date: Thu, 28 Mar 2013 11:25:17 -0500 From: Eric Sandeen User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: ext4 development CC: Anand Avati , Jan Kara Subject: [PATCH, RFC] ext3: add ioctl to force 32-bit hashes from indexed dirs X-Enigmail-Version: 1.5.1 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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!). Pre-submission-fixes-by: Zach Brown Signed-off-by: Eric Sandeen --- -- 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 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..b88cf19 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 _IOW('f', 13, long) /* * 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..aab217d 100644 --- a/fs/ext3/ioctl.c +++ b/fs/ext3/ioctl.c @@ -251,6 +251,41 @@ group_add_out: mnt_drop_write_file(filp); return err; } + case EXT3_IOC_32BITHASH: { + __u32 hash32bits; + int err = 0; + + if (get_user(hash32bits, (int __user *) arg)) + return -EFAULT; + + /* 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) || !is_dx_dir(inode)) { + err = -EINVAL; + goto out_32bithash; + } + + /* Have we already started readir on this dx dir? */ + if (filp->private_data) { + err = -EINVAL; + goto out_32bithash; + } + + if (hash32bits) + filp->f_mode |= FMODE_32BITHASH; + else + filp->f_mode &= ~FMODE_32BITHASH; +out_32bithash: + spin_unlock(&filp->f_lock); + mutex_unlock(&inode->i_mutex); + return err; + } case FITRIM: { struct super_block *sb = inode->i_sb;