From c79d967de3741ceb60c5bbbf1b6f97eab9a89838 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:40 -0400 Subject: quota: move remount handling into the filesystem Currently do_remount_sb calls into the dquot code to tell it about going from rw to ro and ro to rw. Move this code into the filesystem to not depend on the dquot code in the VFS - note ocfs2 already ignores these calls and handles remount by itself. This gets rid of overloading the quotactl calls and allows to unify the VFS and XFS codepaths in that area later. Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/ufs/super.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'fs/ufs') diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 14743d935a93..be1f7b05bc28 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1248,7 +1248,9 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) struct ufs_super_block_first * usb1; struct ufs_super_block_third * usb3; unsigned new_mount_opt, ufstype; + int enable_quota = 0; unsigned flags; + int err; lock_kernel(); lock_super(sb); @@ -1289,6 +1291,13 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) * fs was mouted as rw, remounting ro */ if (*mount_flags & MS_RDONLY) { + err = vfs_dq_off(sb, 1); + if (err < 0 && err != -ENOSYS) { + unlock_super(sb); + unlock_kernel(); + return -EBUSY; + } + ufs_put_super_internal(sb); usb1->fs_time = cpu_to_fs32(sb, get_seconds()); if ((flags & UFS_ST_MASK) == UFS_ST_SUN @@ -1327,11 +1336,14 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) return -EPERM; } sb->s_flags &= ~MS_RDONLY; + enable_quota = 1; #endif } UFS_SB(sb)->s_mount_opt = new_mount_opt; unlock_super(sb); unlock_kernel(); + if (enable_quota) + vfs_dq_quota_on_remount(sb); return 0; } -- cgit v1.2.3 From 0f0dd62fddcbd0f6830ed8ef3d3426ccc46b9250 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:41 -0400 Subject: quota: kill the vfs_dq_off and vfs_dq_quota_on_remount wrappers Instead of having wrappers in the VFS namespace export the dquot_suspend and dquot_resume helpers directly. Also rename vfs_quota_disable to dquot_disable while we're at it. [Jan Kara: Moved dquot_suspend to quotaops.h and made it inline] Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/ext2/super.c | 7 ++--- fs/ext3/super.c | 8 ++--- fs/ext4/super.c | 8 ++--- fs/jfs/super.c | 8 ++--- fs/ocfs2/super.c | 14 ++++----- fs/quota/dquot.c | 77 +++++++++++++++++++++--------------------------- fs/reiserfs/super.c | 8 ++--- fs/udf/super.c | 6 ++-- fs/ufs/super.c | 8 ++--- include/linux/quotaops.h | 31 ++++++++++++++----- 10 files changed, 85 insertions(+), 90 deletions(-) (limited to 'fs/ufs') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 73346de9af5c..318ebc58bb7b 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1250,9 +1250,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) es->s_mtime = cpu_to_le32(get_seconds()); spin_unlock(&sbi->s_lock); - err = vfs_dq_off(sb, 1); - if (err < 0 && err != -ENOSYS) { - err = -EBUSY; + err = dquot_suspend(sb, -1); + if (err < 0) { spin_lock(&sbi->s_lock); goto restore_opts; } @@ -1281,7 +1280,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) ext2_write_super(sb); - vfs_dq_quota_on_remount(sb); + dquot_resume(sb, -1); } return 0; diff --git a/fs/ext3/super.c b/fs/ext3/super.c index d0f8837b6255..9d5e582b514a 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -2598,11 +2598,9 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) } if (*flags & MS_RDONLY) { - err = vfs_dq_off(sb, 1); - if (err < 0 && err != -ENOSYS) { - err = -EBUSY; + err = dquot_suspend(sb, -1); + if (err < 0) goto restore_opts; - } /* * First of all, the unconditional stuff we have to do @@ -2672,7 +2670,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) unlock_kernel(); if (enable_quota) - vfs_dq_quota_on_remount(sb); + dquot_resume(sb, -1); return 0; restore_opts: sb->s_flags = old_sb_flags; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fb1e191d0fa9..08d31101eb05 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3631,11 +3631,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) } if (*flags & MS_RDONLY) { - err = vfs_dq_off(sb, 1); - if (err < 0 && err != -ENOSYS) { - err = -EBUSY; + err = dquot_suspend(sb, -1); + if (err < 0) goto restore_opts; - } /* * First of all, the unconditional stuff we have to do @@ -3722,7 +3720,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) unlock_super(sb); unlock_kernel(); if (enable_quota) - vfs_dq_quota_on_remount(sb); + dquot_resume(sb, -1); return 0; restore_opts: diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 5329d66a9704..b8a07d4c108e 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -401,14 +401,14 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data) sb->s_flags &= ~MS_RDONLY; unlock_kernel(); - vfs_dq_quota_on_remount(sb); + dquot_resume(sb, -1); return ret; } if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { - rc = vfs_dq_off(sb, 1); - if (rc < 0 && rc != -ENOSYS) { + rc = dquot_suspend(sb, -1); + if (rc < 0) { unlock_kernel(); - return -EBUSY; + return rc; } rc = jfs_umount_rw(sb); JFS_SBI(sb)->flag = flag; diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 66f9984a983c..0773873d590a 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -879,18 +879,14 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend) if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) continue; if (unsuspend) - status = vfs_quota_enable( - sb_dqopt(sb)->files[type], - type, QFMT_OCFS2, - DQUOT_SUSPENDED); + status = dquot_resume(sb, type); else { struct ocfs2_mem_dqinfo *oinfo; /* Cancel periodic syncing before suspending */ oinfo = sb_dqinfo(sb, type)->dqi_priv; cancel_delayed_work_sync(&oinfo->dqi_sync_work); - status = vfs_quota_disable(sb, type, - DQUOT_SUSPENDED); + status = dquot_suspend(sb, type); } if (status < 0) break; @@ -958,8 +954,8 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) /* Turn off quotas. This will remove all dquot structures from * memory and so they will be automatically synced to global * quota files */ - vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED | - DQUOT_LIMITS_ENABLED); + dquot_disable(sb, type, DQUOT_USAGE_ENABLED | + DQUOT_LIMITS_ENABLED); if (!inode) continue; iput(inode); @@ -989,7 +985,7 @@ static int ocfs2_quota_off(struct super_block *sb, int type, int remount) if (remount) return 0; /* Ignore now and handle later in * ocfs2_remount() */ - return vfs_quota_disable(sb, type, DQUOT_LIMITS_ENABLED); + return dquot_disable(sb, type, DQUOT_LIMITS_ENABLED); } static const struct quotactl_ops ocfs2_quotactl_ops = { diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 655a4c52b8c3..cf972283e474 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1865,7 +1865,7 @@ EXPORT_SYMBOL(dquot_file_open); /* * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount) */ -int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags) +int dquot_disable(struct super_block *sb, int type, unsigned int flags) { int cnt, ret = 0; struct quota_info *dqopt = sb_dqopt(sb); @@ -1995,14 +1995,16 @@ put_inodes: } return ret; } -EXPORT_SYMBOL(vfs_quota_disable); +EXPORT_SYMBOL(dquot_disable); int vfs_quota_off(struct super_block *sb, int type, int remount) { - return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED : - (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED)); + BUG_ON(remount); + return dquot_disable(sb, type, + DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); } EXPORT_SYMBOL(vfs_quota_off); + /* * Turn quotas on on a device */ @@ -2120,34 +2122,41 @@ out_fmt: } /* Reenable quotas on remount RW */ -static int vfs_quota_on_remount(struct super_block *sb, int type) +int dquot_resume(struct super_block *sb, int type) { struct quota_info *dqopt = sb_dqopt(sb); struct inode *inode; - int ret; + int ret = 0, cnt; unsigned int flags; - mutex_lock(&dqopt->dqonoff_mutex); - if (!sb_has_quota_suspended(sb, type)) { + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { + if (type != -1 && cnt != type) + continue; + + mutex_lock(&dqopt->dqonoff_mutex); + if (!sb_has_quota_suspended(sb, cnt)) { + mutex_unlock(&dqopt->dqonoff_mutex); + continue; + } + inode = dqopt->files[cnt]; + dqopt->files[cnt] = NULL; + spin_lock(&dq_state_lock); + flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED | + DQUOT_LIMITS_ENABLED, + cnt); + dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, cnt); + spin_unlock(&dq_state_lock); mutex_unlock(&dqopt->dqonoff_mutex); - return 0; - } - inode = dqopt->files[type]; - dqopt->files[type] = NULL; - spin_lock(&dq_state_lock); - flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED | - DQUOT_LIMITS_ENABLED, type); - dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, type); - spin_unlock(&dq_state_lock); - mutex_unlock(&dqopt->dqonoff_mutex); - flags = dquot_generic_flag(flags, type); - ret = vfs_load_quota_inode(inode, type, dqopt->info[type].dqi_fmt_id, - flags); - iput(inode); + flags = dquot_generic_flag(flags, cnt); + ret = vfs_load_quota_inode(inode, cnt, + dqopt->info[cnt].dqi_fmt_id, flags); + iput(inode); + } return ret; } +EXPORT_SYMBOL(dquot_resume); int vfs_quota_on_path(struct super_block *sb, int type, int format_id, struct path *path) @@ -2172,8 +2181,7 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name, struct path path; int error; - if (remount) - return vfs_quota_on_remount(sb, type); + BUG_ON(remount); error = kern_path(name, LOOKUP_FOLLOW, &path); if (!error) { @@ -2196,8 +2204,8 @@ int vfs_quota_enable(struct inode *inode, int type, int format_id, struct quota_info *dqopt = sb_dqopt(sb); /* Just unsuspend quotas? */ - if (flags & DQUOT_SUSPENDED) - return vfs_quota_on_remount(sb, type); + BUG_ON(flags & DQUOT_SUSPENDED); + if (!flags) return 0; /* Just updating flags needed? */ @@ -2263,23 +2271,6 @@ out: } EXPORT_SYMBOL(vfs_quota_on_mount); -/* Wrapper to turn on quotas when remounting rw */ -int vfs_dq_quota_on_remount(struct super_block *sb) -{ - int cnt; - int ret = 0, err; - - if (!sb->s_qcop || !sb->s_qcop->quota_on) - return -ENOSYS; - for (cnt = 0; cnt < MAXQUOTAS; cnt++) { - err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1); - if (err < 0 && !ret) - ret = err; - } - return ret; -} -EXPORT_SYMBOL(vfs_dq_quota_on_remount); - static inline qsize_t qbtos(qsize_t blocks) { return blocks << QIF_DQBLKSIZE_BITS; diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 49a8ba02bc17..5dad5a2707bc 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1243,11 +1243,9 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) /* it is read-only already */ goto out_ok; - err = vfs_dq_off(s, 1); - if (err < 0 && err != -ENOSYS) { - err = -EBUSY; + err = dquot_suspend(s, -1); + if (err < 0) goto out_err; - } /* try to remount file system with read-only permissions */ if (sb_umount_state(rs) == REISERFS_VALID_FS @@ -1302,7 +1300,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) s->s_dirt = 0; if (!(*mount_flags & MS_RDONLY)) { - vfs_dq_quota_on_remount(s); + dquot_resume(s, -1); finish_unfinished(s); reiserfs_xattr_init(s, *mount_flags); } diff --git a/fs/udf/super.c b/fs/udf/super.c index 9ab4e259404b..b154c41a7a9a 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -590,15 +590,13 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) if (*flags & MS_RDONLY) { udf_close_lvid(sb); - error = vfs_dq_off(sb, 1); - if (error < 0 && error != -ENOSYS) - error = -EBUSY; + error = dquot_suspend(sb, -1); } else { udf_open_lvid(sb); /* mark the fs r/w for quota activity */ sb->s_flags &= ~MS_RDONLY; - vfs_dq_quota_on_remount(sb); + dquot_resume(sb, -1); } out_unlock: diff --git a/fs/ufs/super.c b/fs/ufs/super.c index be1f7b05bc28..495fdc1df7eb 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1291,11 +1291,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) * fs was mouted as rw, remounting ro */ if (*mount_flags & MS_RDONLY) { - err = vfs_dq_off(sb, 1); - if (err < 0 && err != -ENOSYS) { + err = dquot_suspend(sb, -1); + if (err < 0) { unlock_super(sb); unlock_kernel(); - return -EBUSY; + return err; } ufs_put_super_internal(sb); @@ -1343,7 +1343,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) unlock_super(sb); unlock_kernel(); if (enable_quota) - vfs_dq_quota_on_remount(sb); + dquot_resume(sb, -1); return 0; } diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 370abb1e99cb..811529241e33 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -50,6 +50,14 @@ int dquot_alloc_inode(const struct inode *inode); int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); void dquot_free_inode(const struct inode *inode); +int dquot_disable(struct super_block *sb, int type, unsigned int flags); +/* Suspend quotas on remount RO */ +static inline int dquot_suspend(struct super_block *sb, int type) +{ + return dquot_disable(sb, type, DQUOT_SUSPENDED); +} +int dquot_resume(struct super_block *sb, int type); + int dquot_commit(struct dquot *dquot); int dquot_acquire(struct dquot *dquot); int dquot_release(struct dquot *dquot); @@ -67,7 +75,6 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id, int vfs_quota_on_mount(struct super_block *sb, char *qf_name, int format_id, int type); int vfs_quota_off(struct super_block *sb, int type, int remount); -int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); int vfs_quota_sync(struct super_block *sb, int type, int wait); int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); @@ -78,7 +85,6 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); int dquot_transfer(struct inode *inode, struct iattr *iattr); -int vfs_dq_quota_on_remount(struct super_block *sb); static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) { @@ -231,11 +237,6 @@ static inline int vfs_dq_off(struct super_block *sb, int remount) return 0; } -static inline int vfs_dq_quota_on_remount(struct super_block *sb) -{ - return 0; -} - static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) { return 0; @@ -262,6 +263,22 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) return 0; } +static inline int dquot_disable(struct super_block *sb, int type, + unsigned int flags) +{ + return 0; +} + +static inline int dquot_suspend(struct super_block *sb, int type) +{ + return 0; +} + +static inline int dquot_resume(struct super_block *sb, int type) +{ + return 0; +} + #define dquot_file_open generic_file_open #endif /* CONFIG_QUOTA */ -- cgit v1.2.3 From e0ccfd959cd8907bcb66cc2042e0f4fd7fcbff2b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:42 -0400 Subject: quota: move unmount handling into the filesystem Currently the VFS calls into the quotactl interface for unmounting filesystems. This means filesystems with their own quota handling can't easily distinguish between user-space originating quotaoff and an unount. Instead move the responsibily of the unmount handling into the filesystem to be consistent with all other dquot handling. Note that we do call dquot_disable a lot later now, e.g. after a sync_filesystem. But this is fine as the quota code does all its writes via blockdev's mapping and that is synced even later. Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/ext2/super.c | 2 ++ fs/ext3/super.c | 2 ++ fs/ext4/super.c | 2 ++ fs/jfs/super.c | 2 ++ fs/reiserfs/super.c | 2 ++ fs/super.c | 1 - fs/udf/super.c | 2 ++ fs/ufs/super.c | 2 ++ include/linux/quotaops.h | 15 --------------- 9 files changed, 14 insertions(+), 16 deletions(-) (limited to 'fs/ufs') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 318ebc58bb7b..b9b77c3e7ae0 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -119,6 +119,8 @@ static void ext2_put_super (struct super_block * sb) int i; struct ext2_sb_info *sbi = EXT2_SB(sb); + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + if (sb->s_dirt) ext2_write_super(sb); diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 9d5e582b514a..b2f3715988ba 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -410,6 +410,8 @@ static void ext3_put_super (struct super_block * sb) struct ext3_super_block *es = sbi->s_es; int i, err; + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + lock_kernel(); ext3_xattr_put_super(sb); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 08d31101eb05..808aca3a22f5 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -645,6 +645,8 @@ static void ext4_put_super(struct super_block *sb) struct ext4_super_block *es = sbi->s_es; int i, err; + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + flush_workqueue(sbi->dio_unwritten_wq); destroy_workqueue(sbi->dio_unwritten_wq); diff --git a/fs/jfs/super.c b/fs/jfs/super.c index b8a07d4c108e..7d940a3a3d93 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -179,6 +179,8 @@ static void jfs_put_super(struct super_block *sb) jfs_info("In jfs_put_super"); + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + lock_kernel(); rc = jfs_umount(sb); diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 5dad5a2707bc..08879af0af0d 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -466,6 +466,8 @@ static void reiserfs_put_super(struct super_block *s) struct reiserfs_transaction_handle th; th.t_trans_id = 0; + dquot_disable(s, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + reiserfs_write_lock(s); if (s->s_dirt) diff --git a/fs/super.c b/fs/super.c index a38e6e9b6f69..05f62e5d464d 100644 --- a/fs/super.c +++ b/fs/super.c @@ -160,7 +160,6 @@ void deactivate_locked_super(struct super_block *s) { struct file_system_type *fs = s->s_type; if (atomic_dec_and_test(&s->s_active)) { - vfs_dq_off(s, 0); fs->kill_sb(s); put_filesystem(fs); put_super(s); diff --git a/fs/udf/super.c b/fs/udf/super.c index b154c41a7a9a..76a61566f299 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -2102,6 +2102,8 @@ static void udf_put_super(struct super_block *sb) int i; struct udf_sb_info *sbi; + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + sbi = UDF_SB(sb); lock_kernel(); diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 495fdc1df7eb..d3977c7128e3 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1227,6 +1227,8 @@ static void ufs_put_super(struct super_block *sb) UFSD("ENTER\n"); + dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); + if (sb->s_dirt) ufs_write_super(sb); diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 811529241e33..cfa2abb1b6d1 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -156,16 +156,6 @@ extern const struct quotactl_ops vfs_quotactl_ops; #define sb_dquot_ops (&dquot_operations) #define sb_quotactl_ops (&vfs_quotactl_ops) -/* Cannot be called inside a transaction */ -static inline int vfs_dq_off(struct super_block *sb, int remount) -{ - int ret = -ENOSYS; - - if (sb->s_qcop && sb->s_qcop->quota_off) - ret = sb->s_qcop->quota_off(sb, -1, remount); - return ret; -} - #else static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) @@ -232,11 +222,6 @@ static inline void dquot_free_inode(const struct inode *inode) { } -static inline int vfs_dq_off(struct super_block *sb, int remount) -{ - return 0; -} - static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) { return 0; -- cgit v1.2.3 From 123e9caf1e85008ab7eb5f6cd58c44f9a5d73b2b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:44 -0400 Subject: quota: explicitly set ->dq_op and ->s_qcop Only set the quota operation vectors if the filesystem actually supports quota instead of doing it for all filesystems in alloc_super(). [Jan Kara: Export dquot_operations and vfs_quotactl_ops] Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/ext2/super.c | 6 ++++++ fs/jfs/super.c | 4 ++++ fs/quota/dquot.c | 3 ++- fs/super.c | 3 --- fs/udf/super.c | 6 +++++- fs/ufs/super.c | 6 +++++- include/linux/quotaops.h | 9 --------- 7 files changed, 22 insertions(+), 15 deletions(-) (limited to 'fs/ufs') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index b9b77c3e7ae0..df752b71b869 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1065,6 +1065,12 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_op = &ext2_sops; sb->s_export_op = &ext2_export_ops; sb->s_xattr = ext2_xattr_handlers; + +#ifdef CONFIG_QUOTA + sb->dq_op = &dquot_operations; + sb->s_qcop = &vfs_quotactl_ops; +#endif + root = ext2_iget(sb, EXT2_ROOT_INO); if (IS_ERR(root)) { ret = PTR_ERR(root); diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 7d940a3a3d93..2e7ec5e8cda4 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -481,6 +481,10 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) */ sb->s_op = &jfs_super_operations; sb->s_export_op = &jfs_export_operations; +#ifdef CONFIG_QUOTA + sb->dq_op = &dquot_operations; + sb->s_qcop = &vfs_quotactl_ops; +#endif /* * Initialize direct-mapping inode/address-space diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index b84422657f6d..9ba526e3f719 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -1847,6 +1847,7 @@ const struct dquot_operations dquot_operations = { .alloc_dquot = dquot_alloc, .destroy_dquot = dquot_destroy, }; +EXPORT_SYMBOL(dquot_operations); /* * Generic helper for ->open on filesystems supporting disk quotas. @@ -2491,7 +2492,7 @@ const struct quotactl_ops vfs_quotactl_ops = { .get_dqblk = vfs_get_dqblk, .set_dqblk = vfs_set_dqblk }; - +EXPORT_SYMBOL(vfs_quotactl_ops); static int do_proc_dqstats(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) diff --git a/fs/super.c b/fs/super.c index 05f62e5d464d..af9fd02185aa 100644 --- a/fs/super.c +++ b/fs/super.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include /* for the emergency remount stuff */ @@ -94,8 +93,6 @@ static struct super_block *alloc_super(struct file_system_type *type) init_rwsem(&s->s_dquot.dqptr_sem); init_waitqueue_head(&s->s_wait_unfrozen); s->s_maxbytes = MAX_NON_LFS; - s->dq_op = sb_dquot_ops; - s->s_qcop = sb_quotactl_ops; s->s_op = &default_op; s->s_time_gran = 1000000000; } diff --git a/fs/udf/super.c b/fs/udf/super.c index 76a61566f299..ef9221b7456e 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1948,7 +1948,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) /* Fill in the rest of the superblock */ sb->s_op = &udf_sb_ops; sb->s_export_op = &udf_export_ops; - sb->dq_op = NULL; +#ifdef CONFIG_QUOTA + sb->s_qcop = &vfs_quotactl_ops; + sb->dq_op = NULL; /* &dquot_operations */ +#endif + sb->s_dirt = 0; sb->s_magic = UDF_SUPER_MAGIC; sb->s_time_gran = 1000; diff --git a/fs/ufs/super.c b/fs/ufs/super.c index d3977c7128e3..60c989b7012f 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1045,7 +1045,11 @@ magic_found: */ sb->s_op = &ufs_super_ops; sb->s_export_op = &ufs_export_ops; - sb->dq_op = NULL; /***/ +#ifdef CONFIG_QUOTA + sb->s_qcop = &vfs_quotactl_ops; + sb->dq_op = NULL; /* &dquot_operations */ +#endif + sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); uspi->s_sblkno = fs32_to_cpu(sb, usb1->fs_sblkno); diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index a6592ddc349f..84b8dbf59c03 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -153,9 +153,6 @@ static inline unsigned sb_any_quota_active(struct super_block *sb) extern const struct dquot_operations dquot_operations; extern const struct quotactl_ops vfs_quotactl_ops; -#define sb_dquot_ops (&dquot_operations) -#define sb_quotactl_ops (&vfs_quotactl_ops) - #else static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) @@ -199,12 +196,6 @@ static inline int sb_any_quota_active(struct super_block *sb) return 0; } -/* - * NO-OP when quota not configured. - */ -#define sb_dquot_ops (NULL) -#define sb_quotactl_ops (NULL) - static inline void dquot_initialize(struct inode *inode) { } -- cgit v1.2.3 From 287a80958cf63fc5c68d5bf6e89a3669dd66234a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 19 May 2010 07:16:45 -0400 Subject: quota: rename default quotactl methods to dquot_ Follow the dquot_* style used elsewhere in dquot.c. [Jan Kara: Fixed up missing conversion of ext2] Signed-off-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/ext2/super.c | 2 +- fs/ext3/super.c | 20 +++++++-------- fs/ext4/super.c | 20 +++++++-------- fs/jfs/super.c | 2 +- fs/ocfs2/super.c | 18 +++++++------- fs/quota/dquot.c | 64 ++++++++++++++++++++++++------------------------ fs/reiserfs/super.c | 20 +++++++-------- fs/udf/super.c | 2 +- fs/ufs/super.c | 2 +- include/linux/quotaops.h | 22 ++++++++--------- 10 files changed, 86 insertions(+), 86 deletions(-) (limited to 'fs/ufs') diff --git a/fs/ext2/super.c b/fs/ext2/super.c index df752b71b869..7ff43f4a59cd 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1068,7 +1068,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) #ifdef CONFIG_QUOTA sb->dq_op = &dquot_operations; - sb->s_qcop = &vfs_quotactl_ops; + sb->s_qcop = &dquot_quotactl_ops; #endif root = ext2_iget(sb, EXT2_ROOT_INO); diff --git a/fs/ext3/super.c b/fs/ext3/super.c index e52006737b4b..6c953bb255e7 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -769,12 +769,12 @@ static const struct dquot_operations ext3_quota_operations = { static const struct quotactl_ops ext3_qctl_operations = { .quota_on = ext3_quota_on, - .quota_off = vfs_quota_off, - .quota_sync = vfs_quota_sync, - .get_info = vfs_get_dqinfo, - .set_info = vfs_set_dqinfo, - .get_dqblk = vfs_get_dqblk, - .set_dqblk = vfs_set_dqblk + .quota_off = dquot_quota_off, + .quota_sync = dquot_quota_sync, + .get_info = dquot_get_dqinfo, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk }; #endif @@ -1529,7 +1529,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, /* Turn quotas off */ for (i = 0; i < MAXQUOTAS; i++) { if (sb_dqopt(sb)->files[i]) - vfs_quota_off(sb, i); + dquot_quota_off(sb, i); } #endif sb->s_flags = s_flags; /* Restore MS_RDONLY status */ @@ -2862,8 +2862,8 @@ static int ext3_write_info(struct super_block *sb, int type) */ static int ext3_quota_on_mount(struct super_block *sb, int type) { - return vfs_quota_on_mount(sb, EXT3_SB(sb)->s_qf_names[type], - EXT3_SB(sb)->s_jquota_fmt, type); + return dquot_quota_on_mount(sb, EXT3_SB(sb)->s_qf_names[type], + EXT3_SB(sb)->s_jquota_fmt, type); } /* @@ -2914,7 +2914,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id, } } - err = vfs_quota_on_path(sb, type, format_id, &path); + err = dquot_quota_on_path(sb, type, format_id, &path); path_put(&path); return err; } diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dfe9bf503f85..381e5a931265 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1083,12 +1083,12 @@ static const struct dquot_operations ext4_quota_operations = { static const struct quotactl_ops ext4_qctl_operations = { .quota_on = ext4_quota_on, - .quota_off = vfs_quota_off, - .quota_sync = vfs_quota_sync, - .get_info = vfs_get_dqinfo, - .set_info = vfs_set_dqinfo, - .get_dqblk = vfs_get_dqblk, - .set_dqblk = vfs_set_dqblk + .quota_off = dquot_quota_off, + .quota_sync = dquot_quota_sync, + .get_info = dquot_get_dqinfo, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk }; #endif @@ -2053,7 +2053,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, /* Turn quotas off */ for (i = 0; i < MAXQUOTAS; i++) { if (sb_dqopt(sb)->files[i]) - vfs_quota_off(sb, i); + dquot_quota_off(sb, i); } #endif sb->s_flags = s_flags; /* Restore MS_RDONLY status */ @@ -3916,8 +3916,8 @@ static int ext4_write_info(struct super_block *sb, int type) */ static int ext4_quota_on_mount(struct super_block *sb, int type) { - return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], - EXT4_SB(sb)->s_jquota_fmt, type); + return dquot_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], + EXT4_SB(sb)->s_jquota_fmt, type); } /* @@ -3969,7 +3969,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, } } - err = vfs_quota_on_path(sb, type, format_id, &path); + err = dquot_quota_on_path(sb, type, format_id, &path); path_put(&path); return err; } diff --git a/fs/jfs/super.c b/fs/jfs/super.c index 2e7ec5e8cda4..b38f96bef829 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -483,7 +483,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) sb->s_export_op = &jfs_export_operations; #ifdef CONFIG_QUOTA sb->dq_op = &dquot_operations; - sb->s_qcop = &vfs_quotactl_ops; + sb->s_qcop = &dquot_quotactl_ops; #endif /* diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 5367d6dee395..0eaa929a4dbf 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -918,8 +918,8 @@ static int ocfs2_enable_quotas(struct ocfs2_super *osb) status = -ENOENT; goto out_quota_off; } - status = vfs_quota_enable(inode[type], type, QFMT_OCFS2, - DQUOT_USAGE_ENABLED); + status = dquot_enable(inode[type], type, QFMT_OCFS2, + DQUOT_USAGE_ENABLED); if (status < 0) goto out_quota_off; } @@ -972,8 +972,8 @@ static int ocfs2_quota_on(struct super_block *sb, int type, int format_id, if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) return -EINVAL; - return vfs_quota_enable(sb_dqopt(sb)->files[type], type, - format_id, DQUOT_LIMITS_ENABLED); + return dquot_enable(sb_dqopt(sb)->files[type], type, + format_id, DQUOT_LIMITS_ENABLED); } /* Handle quota off quotactl */ @@ -985,11 +985,11 @@ static int ocfs2_quota_off(struct super_block *sb, int type) static const struct quotactl_ops ocfs2_quotactl_ops = { .quota_on = ocfs2_quota_on, .quota_off = ocfs2_quota_off, - .quota_sync = vfs_quota_sync, - .get_info = vfs_get_dqinfo, - .set_info = vfs_set_dqinfo, - .get_dqblk = vfs_get_dqblk, - .set_dqblk = vfs_set_dqblk, + .quota_sync = dquot_quota_sync, + .get_info = dquot_get_dqinfo, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk, }; static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 9ba526e3f719..1914a2f6c84c 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -584,7 +584,7 @@ out: } EXPORT_SYMBOL(dquot_scan_active); -int vfs_quota_sync(struct super_block *sb, int type, int wait) +int dquot_quota_sync(struct super_block *sb, int type, int wait) { struct list_head *dirty; struct dquot *dquot; @@ -656,7 +656,7 @@ int vfs_quota_sync(struct super_block *sb, int type, int wait) return 0; } -EXPORT_SYMBOL(vfs_quota_sync); +EXPORT_SYMBOL(dquot_quota_sync); /* Free unused dquots from cache */ static void prune_dqcache(int count) @@ -1998,12 +1998,12 @@ put_inodes: } EXPORT_SYMBOL(dquot_disable); -int vfs_quota_off(struct super_block *sb, int type) +int dquot_quota_off(struct super_block *sb, int type) { return dquot_disable(sb, type, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); } -EXPORT_SYMBOL(vfs_quota_off); +EXPORT_SYMBOL(dquot_quota_off); /* * Turn quotas on on a device @@ -2158,7 +2158,7 @@ int dquot_resume(struct super_block *sb, int type) } EXPORT_SYMBOL(dquot_resume); -int vfs_quota_on_path(struct super_block *sb, int type, int format_id, +int dquot_quota_on_path(struct super_block *sb, int type, int format_id, struct path *path) { int error = security_quota_on(path->dentry); @@ -2173,28 +2173,28 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id, DQUOT_LIMITS_ENABLED); return error; } -EXPORT_SYMBOL(vfs_quota_on_path); +EXPORT_SYMBOL(dquot_quota_on_path); -int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name) +int dquot_quota_on(struct super_block *sb, int type, int format_id, char *name) { struct path path; int error; error = kern_path(name, LOOKUP_FOLLOW, &path); if (!error) { - error = vfs_quota_on_path(sb, type, format_id, &path); + error = dquot_quota_on_path(sb, type, format_id, &path); path_put(&path); } return error; } -EXPORT_SYMBOL(vfs_quota_on); +EXPORT_SYMBOL(dquot_quota_on); /* * More powerful function for turning on quotas allowing setting * of individual quota flags */ -int vfs_quota_enable(struct inode *inode, int type, int format_id, - unsigned int flags) +int dquot_enable(struct inode *inode, int type, int format_id, + unsigned int flags) { int ret = 0; struct super_block *sb = inode->i_sb; @@ -2234,13 +2234,13 @@ out_lock: load_quota: return vfs_load_quota_inode(inode, type, format_id, flags); } -EXPORT_SYMBOL(vfs_quota_enable); +EXPORT_SYMBOL(dquot_enable); /* * This function is used when filesystem needs to initialize quotas * during mount time. */ -int vfs_quota_on_mount(struct super_block *sb, char *qf_name, +int dquot_quota_on_mount(struct super_block *sb, char *qf_name, int format_id, int type) { struct dentry *dentry; @@ -2266,7 +2266,7 @@ out: dput(dentry); return error; } -EXPORT_SYMBOL(vfs_quota_on_mount); +EXPORT_SYMBOL(dquot_quota_on_mount); static inline qsize_t qbtos(qsize_t blocks) { @@ -2301,8 +2301,8 @@ static void do_get_dqblk(struct dquot *dquot, struct fs_disk_quota *di) spin_unlock(&dq_data_lock); } -int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, - struct fs_disk_quota *di) +int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, + struct fs_disk_quota *di) { struct dquot *dquot; @@ -2314,7 +2314,7 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, return 0; } -EXPORT_SYMBOL(vfs_get_dqblk); +EXPORT_SYMBOL(dquot_get_dqblk); #define VFS_FS_DQ_MASK \ (FS_DQ_BCOUNT | FS_DQ_BSOFT | FS_DQ_BHARD | \ @@ -2413,7 +2413,7 @@ static int do_set_dqblk(struct dquot *dquot, struct fs_disk_quota *di) return 0; } -int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, +int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, struct fs_disk_quota *di) { struct dquot *dquot; @@ -2429,10 +2429,10 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, out: return rc; } -EXPORT_SYMBOL(vfs_set_dqblk); +EXPORT_SYMBOL(dquot_set_dqblk); /* Generic routine for getting common part of quota file information */ -int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) +int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) { struct mem_dqinfo *mi; @@ -2451,10 +2451,10 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); return 0; } -EXPORT_SYMBOL(vfs_get_dqinfo); +EXPORT_SYMBOL(dquot_get_dqinfo); /* Generic routine for setting common part of quota file information */ -int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) +int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) { struct mem_dqinfo *mi; int err = 0; @@ -2481,18 +2481,18 @@ out: mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); return err; } -EXPORT_SYMBOL(vfs_set_dqinfo); +EXPORT_SYMBOL(dquot_set_dqinfo); -const struct quotactl_ops vfs_quotactl_ops = { - .quota_on = vfs_quota_on, - .quota_off = vfs_quota_off, - .quota_sync = vfs_quota_sync, - .get_info = vfs_get_dqinfo, - .set_info = vfs_set_dqinfo, - .get_dqblk = vfs_get_dqblk, - .set_dqblk = vfs_set_dqblk +const struct quotactl_ops dquot_quotactl_ops = { + .quota_on = dquot_quota_on, + .quota_off = dquot_quota_off, + .quota_sync = dquot_quota_sync, + .get_info = dquot_get_dqinfo, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk }; -EXPORT_SYMBOL(vfs_quotactl_ops); +EXPORT_SYMBOL(dquot_quotactl_ops); static int do_proc_dqstats(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index fa46abd0d958..f0ab5c94139c 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -305,7 +305,7 @@ static int finish_unfinished(struct super_block *s) /* Turn quotas off */ for (i = 0; i < MAXQUOTAS; i++) { if (sb_dqopt(s)->files[i]) - vfs_quota_off(s, i); + dquot_quota_off(s, i); } if (ms_active_set) /* Restore the flag back */ @@ -636,12 +636,12 @@ static const struct dquot_operations reiserfs_quota_operations = { static const struct quotactl_ops reiserfs_qctl_operations = { .quota_on = reiserfs_quota_on, - .quota_off = vfs_quota_off, - .quota_sync = vfs_quota_sync, - .get_info = vfs_get_dqinfo, - .set_info = vfs_set_dqinfo, - .get_dqblk = vfs_get_dqblk, - .set_dqblk = vfs_set_dqblk, + .quota_off = dquot_quota_off, + .quota_sync = dquot_quota_sync, + .get_info = dquot_get_dqinfo, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk, }; #endif @@ -2030,8 +2030,8 @@ static int reiserfs_write_info(struct super_block *sb, int type) */ static int reiserfs_quota_on_mount(struct super_block *sb, int type) { - return vfs_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type], - REISERFS_SB(sb)->s_jquota_fmt, type); + return dquot_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type], + REISERFS_SB(sb)->s_jquota_fmt, type); } /* @@ -2091,7 +2091,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, if (err) goto out; } - err = vfs_quota_on_path(sb, type, format_id, &path); + err = dquot_quota_on_path(sb, type, format_id, &path); out: path_put(&path); return err; diff --git a/fs/udf/super.c b/fs/udf/super.c index ef9221b7456e..5e03592369d7 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1949,7 +1949,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) sb->s_op = &udf_sb_ops; sb->s_export_op = &udf_export_ops; #ifdef CONFIG_QUOTA - sb->s_qcop = &vfs_quotactl_ops; + sb->s_qcop = &dquot_quotactl_ops; sb->dq_op = NULL; /* &dquot_operations */ #endif diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 60c989b7012f..2b08a8dd8ec0 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -1046,7 +1046,7 @@ magic_found: sb->s_op = &ufs_super_ops; sb->s_export_op = &ufs_export_ops; #ifdef CONFIG_QUOTA - sb->s_qcop = &vfs_quotactl_ops; + sb->s_qcop = &dquot_quotactl_ops; sb->dq_op = NULL; /* &dquot_operations */ #endif diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 84b8dbf59c03..0c77cd8d2822 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -66,21 +66,21 @@ int dquot_mark_dquot_dirty(struct dquot *dquot); int dquot_file_open(struct inode *inode, struct file *file); -int vfs_quota_on(struct super_block *sb, int type, int format_id, +int dquot_quota_on(struct super_block *sb, int type, int format_id, char *path); -int vfs_quota_enable(struct inode *inode, int type, int format_id, +int dquot_enable(struct inode *inode, int type, int format_id, unsigned int flags); -int vfs_quota_on_path(struct super_block *sb, int type, int format_id, +int dquot_quota_on_path(struct super_block *sb, int type, int format_id, struct path *path); -int vfs_quota_on_mount(struct super_block *sb, char *qf_name, +int dquot_quota_on_mount(struct super_block *sb, char *qf_name, int format_id, int type); -int vfs_quota_off(struct super_block *sb, int type); -int vfs_quota_sync(struct super_block *sb, int type, int wait); -int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); -int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); -int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, +int dquot_quota_off(struct super_block *sb, int type); +int dquot_quota_sync(struct super_block *sb, int type, int wait); +int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); +int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); +int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, struct fs_disk_quota *di); -int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, +int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, struct fs_disk_quota *di); int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); @@ -151,7 +151,7 @@ static inline unsigned sb_any_quota_active(struct super_block *sb) * Operations supported for diskquotas. */ extern const struct dquot_operations dquot_operations; -extern const struct quotactl_ops vfs_quotactl_ops; +extern const struct quotactl_ops dquot_quotactl_ops; #else -- cgit v1.2.3 From 8f45c33decf62e1aaaa9411aae8fef6a38f95845 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 20 May 2010 16:00:36 +0200 Subject: ufs: Remove dead quota code UFS quota is non-functional at least since 2.6.12 because dq_op was set to NULL. Since the filesystem exists mainly to allow cooperation with Solaris and quota format isn't standard, just remove the dead code. CC: Evgeniy Dushistov Signed-off-by: Jan Kara --- fs/ufs/balloc.c | 24 ----------- fs/ufs/file.c | 3 +- fs/ufs/ialloc.c | 13 ------ fs/ufs/inode.c | 4 -- fs/ufs/namei.c | 16 ------- fs/ufs/super.c | 126 ------------------------------------------------------ fs/ufs/truncate.c | 10 ----- 7 files changed, 1 insertion(+), 195 deletions(-) (limited to 'fs/ufs') diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 5cfa4d85ccf2..048484fb10d2 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -85,9 +84,6 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count) "bit already cleared for fragment %u", i); } - dquot_free_block(inode, count); - - fs32_add(sb, &ucg->cg_cs.cs_nffree, count); uspi->cs_total.cs_nffree += count; fs32_add(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); @@ -195,7 +191,6 @@ do_more: ubh_setblock(UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, 1); - dquot_free_block(inode, uspi->s_fpb); fs32_add(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree++; @@ -511,7 +506,6 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment, struct ufs_cg_private_info * ucpi; struct ufs_cylinder_group * ucg; unsigned cgno, fragno, fragoff, count, fragsize, i; - int ret; UFSD("ENTER, fragment %llu, oldcount %u, newcount %u\n", (unsigned long long)fragment, oldcount, newcount); @@ -557,11 +551,6 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment, fs32_add(sb, &ucg->cg_frsum[fragsize - count], 1); for (i = oldcount; i < newcount; i++) ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i); - ret = dquot_alloc_block(inode, count); - if (ret) { - *err = ret; - return 0; - } fs32_sub(sb, &ucg->cg_cs.cs_nffree, count); fs32_sub(sb, &UFS_SB(sb)->fs_cs(cgno).cs_nffree, count); @@ -598,7 +587,6 @@ static u64 ufs_alloc_fragments(struct inode *inode, unsigned cgno, struct ufs_cylinder_group * ucg; unsigned oldcg, i, j, k, allocsize; u64 result; - int ret; UFSD("ENTER, ino %lu, cgno %u, goal %llu, count %u\n", inode->i_ino, cgno, (unsigned long long)goal, count); @@ -667,7 +655,6 @@ cg_found: for (i = count; i < uspi->s_fpb; i++) ubh_setbit (UCPI_UBH(ucpi), ucpi->c_freeoff, goal + i); i = uspi->s_fpb - count; - dquot_free_block(inode, i); fs32_add(sb, &ucg->cg_cs.cs_nffree, i); uspi->cs_total.cs_nffree += i; @@ -679,11 +666,6 @@ cg_found: result = ufs_bitmap_search (sb, ucpi, goal, allocsize); if (result == INVBLOCK) return 0; - ret = dquot_alloc_block(inode, count); - if (ret) { - *err = ret; - return 0; - } for (i = 0; i < count; i++) ubh_clrbit (UCPI_UBH(ucpi), ucpi->c_freeoff, result + i); @@ -718,7 +700,6 @@ static u64 ufs_alloccg_block(struct inode *inode, struct ufs_super_block_first * usb1; struct ufs_cylinder_group * ucg; u64 result, blkno; - int ret; UFSD("ENTER, goal %llu\n", (unsigned long long)goal); @@ -752,11 +733,6 @@ gotit: ubh_clrblock (UCPI_UBH(ucpi), ucpi->c_freeoff, blkno); if ((UFS_SB(sb)->s_flags & UFS_CG_MASK) == UFS_CG_44BSD) ufs_clusteracct (sb, ucpi, blkno, -1); - ret = dquot_alloc_block(inode, uspi->s_fpb); - if (ret) { - *err = ret; - return INVBLOCK; - } fs32_sub(sb, &ucg->cg_cs.cs_nbfree, 1); uspi->cs_total.cs_nbfree--; diff --git a/fs/ufs/file.c b/fs/ufs/file.c index a8962cecde5b..73655c61240a 100644 --- a/fs/ufs/file.c +++ b/fs/ufs/file.c @@ -24,7 +24,6 @@ */ #include -#include #include "ufs_fs.h" #include "ufs.h" @@ -41,7 +40,7 @@ const struct file_operations ufs_file_operations = { .write = do_sync_write, .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, - .open = dquot_file_open, + .open = generic_file_open, .fsync = simple_fsync, .splice_read = generic_file_splice_read, }; diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index 3a959d55084d..594480e537d2 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -95,9 +94,6 @@ void ufs_free_inode (struct inode * inode) is_directory = S_ISDIR(inode->i_mode); - dquot_free_inode(inode); - dquot_drop(inode); - clear_inode (inode); if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_iusedoff, bit)) @@ -347,21 +343,12 @@ cg_found: unlock_super (sb); - dquot_initialize(inode); - err = dquot_alloc_inode(inode); - if (err) { - dquot_drop(inode); - goto fail_without_unlock; - } - UFSD("allocating inode %lu\n", inode->i_ino); UFSD("EXIT\n"); return inode; fail_remove_inode: unlock_super(sb); -fail_without_unlock: - inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; iput(inode); UFSD("EXIT (FAILED): err %d\n", err); diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index cffa756f1047..73fe773aa034 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "ufs_fs.h" #include "ufs.h" @@ -910,9 +909,6 @@ void ufs_delete_inode (struct inode * inode) { loff_t old_i_size; - if (!is_bad_inode(inode)) - dquot_initialize(inode); - truncate_inode_pages(&inode->i_data, 0); if (is_bad_inode(inode)) goto no_delete; diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index eabc02eb1294..b056f02b1fb3 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -30,7 +30,6 @@ #include #include #include -#include #include "ufs_fs.h" #include "ufs.h" @@ -86,8 +85,6 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, int mode, UFSD("BEGIN\n"); - dquot_initialize(dir); - inode = ufs_new_inode(dir, mode); err = PTR_ERR(inode); @@ -112,8 +109,6 @@ static int ufs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t if (!old_valid_dev(rdev)) return -EINVAL; - dquot_initialize(dir); - inode = ufs_new_inode(dir, mode); err = PTR_ERR(inode); if (!IS_ERR(inode)) { @@ -138,8 +133,6 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, if (l > sb->s_blocksize) goto out_notlocked; - dquot_initialize(dir); - lock_kernel(); inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO); err = PTR_ERR(inode); @@ -185,8 +178,6 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir, return -EMLINK; } - dquot_initialize(dir); - inode->i_ctime = CURRENT_TIME_SEC; inode_inc_link_count(inode); atomic_inc(&inode->i_count); @@ -204,8 +195,6 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode) if (dir->i_nlink >= UFS_LINK_MAX) goto out; - dquot_initialize(dir); - lock_kernel(); inode_inc_link_count(dir); @@ -250,8 +239,6 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry) struct page *page; int err = -ENOENT; - dquot_initialize(dir); - de = ufs_find_entry(dir, &dentry->d_name, &page); if (!de) goto out; @@ -296,9 +283,6 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, struct ufs_dir_entry *old_de; int err = -ENOENT; - dquot_initialize(old_dir); - dquot_initialize(new_dir); - old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page); if (!old_de) goto out; diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 2b08a8dd8ec0..3c9bbf23c2ff 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -77,7 +77,6 @@ #include #include -#include #include #include #include @@ -1045,10 +1044,6 @@ magic_found: */ sb->s_op = &ufs_super_ops; sb->s_export_op = &ufs_export_ops; -#ifdef CONFIG_QUOTA - sb->s_qcop = &dquot_quotactl_ops; - sb->dq_op = NULL; /* &dquot_operations */ -#endif sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); @@ -1231,8 +1226,6 @@ static void ufs_put_super(struct super_block *sb) UFSD("ENTER\n"); - dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); - if (sb->s_dirt) ufs_write_super(sb); @@ -1254,9 +1247,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) struct ufs_super_block_first * usb1; struct ufs_super_block_third * usb3; unsigned new_mount_opt, ufstype; - int enable_quota = 0; unsigned flags; - int err; lock_kernel(); lock_super(sb); @@ -1297,13 +1288,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) * fs was mouted as rw, remounting ro */ if (*mount_flags & MS_RDONLY) { - err = dquot_suspend(sb, -1); - if (err < 0) { - unlock_super(sb); - unlock_kernel(); - return err; - } - ufs_put_super_internal(sb); usb1->fs_time = cpu_to_fs32(sb, get_seconds()); if ((flags & UFS_ST_MASK) == UFS_ST_SUN @@ -1342,14 +1326,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) return -EPERM; } sb->s_flags &= ~MS_RDONLY; - enable_quota = 1; #endif } UFS_SB(sb)->s_mount_opt = new_mount_opt; unlock_super(sb); unlock_kernel(); - if (enable_quota) - dquot_resume(sb, -1); return 0; } @@ -1453,126 +1434,19 @@ static void destroy_inodecache(void) kmem_cache_destroy(ufs_inode_cachep); } -static void ufs_clear_inode(struct inode *inode) -{ - dquot_drop(inode); -} - -#ifdef CONFIG_QUOTA -static ssize_t ufs_quota_read(struct super_block *, int, char *,size_t, loff_t); -static ssize_t ufs_quota_write(struct super_block *, int, const char *, size_t, loff_t); -#endif - static const struct super_operations ufs_super_ops = { .alloc_inode = ufs_alloc_inode, .destroy_inode = ufs_destroy_inode, .write_inode = ufs_write_inode, .delete_inode = ufs_delete_inode, - .clear_inode = ufs_clear_inode, .put_super = ufs_put_super, .write_super = ufs_write_super, .sync_fs = ufs_sync_fs, .statfs = ufs_statfs, .remount_fs = ufs_remount, .show_options = ufs_show_options, -#ifdef CONFIG_QUOTA - .quota_read = ufs_quota_read, - .quota_write = ufs_quota_write, -#endif }; -#ifdef CONFIG_QUOTA - -/* Read data from quotafile - avoid pagecache and such because we cannot afford - * acquiring the locks... As quota files are never truncated and quota code - * itself serializes the operations (and noone else should touch the files) - * we don't have to be afraid of races */ -static ssize_t ufs_quota_read(struct super_block *sb, int type, char *data, - size_t len, loff_t off) -{ - struct inode *inode = sb_dqopt(sb)->files[type]; - sector_t blk = off >> sb->s_blocksize_bits; - int err = 0; - int offset = off & (sb->s_blocksize - 1); - int tocopy; - size_t toread; - struct buffer_head *bh; - loff_t i_size = i_size_read(inode); - - if (off > i_size) - return 0; - if (off+len > i_size) - len = i_size-off; - toread = len; - while (toread > 0) { - tocopy = sb->s_blocksize - offset < toread ? - sb->s_blocksize - offset : toread; - - bh = ufs_bread(inode, blk, 0, &err); - if (err) - return err; - if (!bh) /* A hole? */ - memset(data, 0, tocopy); - else { - memcpy(data, bh->b_data+offset, tocopy); - brelse(bh); - } - offset = 0; - toread -= tocopy; - data += tocopy; - blk++; - } - return len; -} - -/* Write to quotafile */ -static ssize_t ufs_quota_write(struct super_block *sb, int type, - const char *data, size_t len, loff_t off) -{ - struct inode *inode = sb_dqopt(sb)->files[type]; - sector_t blk = off >> sb->s_blocksize_bits; - int err = 0; - int offset = off & (sb->s_blocksize - 1); - int tocopy; - size_t towrite = len; - struct buffer_head *bh; - - mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); - while (towrite > 0) { - tocopy = sb->s_blocksize - offset < towrite ? - sb->s_blocksize - offset : towrite; - - bh = ufs_bread(inode, blk, 1, &err); - if (!bh) - goto out; - lock_buffer(bh); - memcpy(bh->b_data+offset, data, tocopy); - flush_dcache_page(bh->b_page); - set_buffer_uptodate(bh); - mark_buffer_dirty(bh); - unlock_buffer(bh); - brelse(bh); - offset = 0; - towrite -= tocopy; - data += tocopy; - blk++; - } -out: - if (len == towrite) { - mutex_unlock(&inode->i_mutex); - return err; - } - if (inode->i_size < off+len-towrite) - i_size_write(inode, off+len-towrite); - inode->i_version++; - inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; - mark_inode_dirty(inode); - mutex_unlock(&inode->i_mutex); - return len - towrite; -} - -#endif - static int ufs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt) { diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c index f294c44577dc..4171e2df18dd 100644 --- a/fs/ufs/truncate.c +++ b/fs/ufs/truncate.c @@ -44,7 +44,6 @@ #include #include #include -#include #include "ufs_fs.h" #include "ufs.h" @@ -518,15 +517,6 @@ int ufs_setattr(struct dentry *dentry, struct iattr *attr) if (error) return error; - if (is_quota_modification(inode, attr)) - dquot_initialize(inode); - - if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { - error = dquot_transfer(inode, attr); - if (error) - return error; - } if (ia_valid & ATTR_SIZE && attr->ia_size != inode->i_size) { loff_t old_i_size = inode->i_size; -- cgit v1.2.3