aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2010-09-15 11:38:58 -0400
committerJan Kara <jack@suse.cz>2011-01-12 13:14:55 -0500
commitf00c9e44ad1a9660fe8cd3ca15b6cd9497172eab (patch)
treecbb47ae0d8aba9d8b3c44714b000156715cdf969 /fs/ext3
parent4162cf64973df51fc885825bc9ca4d055891c49f (diff)
quota: Fix deadlock during path resolution
As Al Viro pointed out path resolution during Q_QUOTAON calls to quotactl is prone to deadlocks. We hold s_umount semaphore for reading during the path resolution and resolution itself may need to acquire the semaphore for writing when e. g. autofs mountpoint is passed. Solve the problem by performing the resolution before we get hold of the superblock (and thus s_umount semaphore). The whole thing is complicated by the fact that some filesystems (OCFS2) ignore the path argument. So to distinguish between filesystem which want the path and which do not we introduce new .quota_on_meta callback which does not get the path. OCFS2 then uses this callback instead of old .quota_on. CC: Al Viro <viro@ZenIV.linux.org.uk> CC: Christoph Hellwig <hch@lst.de> CC: Ted Ts'o <tytso@mit.edu> CC: Joel Becker <joel.becker@oracle.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/super.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index b7d0554631e4..0e0d391626be 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -755,7 +755,7 @@ static int ext3_release_dquot(struct dquot *dquot);
755static int ext3_mark_dquot_dirty(struct dquot *dquot); 755static int ext3_mark_dquot_dirty(struct dquot *dquot);
756static int ext3_write_info(struct super_block *sb, int type); 756static int ext3_write_info(struct super_block *sb, int type);
757static int ext3_quota_on(struct super_block *sb, int type, int format_id, 757static int ext3_quota_on(struct super_block *sb, int type, int format_id,
758 char *path); 758 struct path *path);
759static int ext3_quota_on_mount(struct super_block *sb, int type); 759static int ext3_quota_on_mount(struct super_block *sb, int type);
760static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data, 760static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,
761 size_t len, loff_t off); 761 size_t len, loff_t off);
@@ -2885,27 +2885,20 @@ static int ext3_quota_on_mount(struct super_block *sb, int type)
2885 * Standard function to be called on quota_on 2885 * Standard function to be called on quota_on
2886 */ 2886 */
2887static int ext3_quota_on(struct super_block *sb, int type, int format_id, 2887static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2888 char *name) 2888 struct path *path)
2889{ 2889{
2890 int err; 2890 int err;
2891 struct path path;
2892 2891
2893 if (!test_opt(sb, QUOTA)) 2892 if (!test_opt(sb, QUOTA))
2894 return -EINVAL; 2893 return -EINVAL;
2895 2894
2896 err = kern_path(name, LOOKUP_FOLLOW, &path);
2897 if (err)
2898 return err;
2899
2900 /* Quotafile not on the same filesystem? */ 2895 /* Quotafile not on the same filesystem? */
2901 if (path.mnt->mnt_sb != sb) { 2896 if (path->mnt->mnt_sb != sb)
2902 path_put(&path);
2903 return -EXDEV; 2897 return -EXDEV;
2904 }
2905 /* Journaling quota? */ 2898 /* Journaling quota? */
2906 if (EXT3_SB(sb)->s_qf_names[type]) { 2899 if (EXT3_SB(sb)->s_qf_names[type]) {
2907 /* Quotafile not of fs root? */ 2900 /* Quotafile not of fs root? */
2908 if (path.dentry->d_parent != sb->s_root) 2901 if (path->dentry->d_parent != sb->s_root)
2909 ext3_msg(sb, KERN_WARNING, 2902 ext3_msg(sb, KERN_WARNING,
2910 "warning: Quota file not on filesystem root. " 2903 "warning: Quota file not on filesystem root. "
2911 "Journaled quota will not work."); 2904 "Journaled quota will not work.");
@@ -2915,7 +2908,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2915 * When we journal data on quota file, we have to flush journal to see 2908 * When we journal data on quota file, we have to flush journal to see
2916 * all updates to the file when we bypass pagecache... 2909 * all updates to the file when we bypass pagecache...
2917 */ 2910 */
2918 if (ext3_should_journal_data(path.dentry->d_inode)) { 2911 if (ext3_should_journal_data(path->dentry->d_inode)) {
2919 /* 2912 /*
2920 * We don't need to lock updates but journal_flush() could 2913 * We don't need to lock updates but journal_flush() could
2921 * otherwise be livelocked... 2914 * otherwise be livelocked...
@@ -2923,15 +2916,11 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2923 journal_lock_updates(EXT3_SB(sb)->s_journal); 2916 journal_lock_updates(EXT3_SB(sb)->s_journal);
2924 err = journal_flush(EXT3_SB(sb)->s_journal); 2917 err = journal_flush(EXT3_SB(sb)->s_journal);
2925 journal_unlock_updates(EXT3_SB(sb)->s_journal); 2918 journal_unlock_updates(EXT3_SB(sb)->s_journal);
2926 if (err) { 2919 if (err)
2927 path_put(&path);
2928 return err; 2920 return err;
2929 }
2930 } 2921 }
2931 2922
2932 err = dquot_quota_on_path(sb, type, format_id, &path); 2923 return dquot_quota_on(sb, type, format_id, path);
2933 path_put(&path);
2934 return err;
2935} 2924}
2936 2925
2937/* Read data from quotafile - avoid pagecache and such because we cannot afford 2926/* Read data from quotafile - avoid pagecache and such because we cannot afford