Skip to content

Commit 12fd086

Browse files
committed
jfs: Set flags on quota files directly
Currently immutable and noatime flags on quota files are set by quota code which requires us to copy inode->i_flags to our on disk version of quota flags in GETFLAGS ioctl and copy_to_dinode(). Move to setting / clearing these on-disk flags directly to save that copying. Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 161f3b7 commit 12fd086

1 file changed

Lines changed: 77 additions & 2 deletions

File tree

‎fs/jfs/super.c‎

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "jfs_acl.h"
4646
#include "jfs_debug.h"
4747
#include "jfs_xattr.h"
48+
#include "jfs_dinode.h"
4849

4950
MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
5051
MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
@@ -181,14 +182,43 @@ static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
181182
return 0;
182183
}
183184

185+
#ifdef CONFIG_QUOTA
186+
static int jfs_quota_off(struct super_block *sb, int type);
187+
static int jfs_quota_on(struct super_block *sb, int type, int format_id,
188+
const struct path *path);
189+
190+
static void jfs_quota_off_umount(struct super_block *sb)
191+
{
192+
int type;
193+
194+
for (type = 0; type < MAXQUOTAS; type++)
195+
jfs_quota_off(sb, type);
196+
}
197+
198+
static const struct quotactl_ops jfs_quotactl_ops = {
199+
.quota_on = jfs_quota_on,
200+
.quota_off = jfs_quota_off,
201+
.quota_sync = dquot_quota_sync,
202+
.get_state = dquot_get_state,
203+
.set_info = dquot_set_dqinfo,
204+
.get_dqblk = dquot_get_dqblk,
205+
.set_dqblk = dquot_set_dqblk,
206+
.get_nextdqblk = dquot_get_next_dqblk,
207+
};
208+
#else
209+
static inline void jfs_quota_off_umount(struct super_block *sb)
210+
{
211+
}
212+
#endif
213+
184214
static void jfs_put_super(struct super_block *sb)
185215
{
186216
struct jfs_sb_info *sbi = JFS_SBI(sb);
187217
int rc;
188218

189219
jfs_info("In jfs_put_super");
190220

191-
dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
221+
jfs_quota_off_umount(sb);
192222

193223
rc = jfs_umount(sb);
194224
if (rc)
@@ -536,7 +566,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
536566
sb->s_xattr = jfs_xattr_handlers;
537567
#ifdef CONFIG_QUOTA
538568
sb->dq_op = &dquot_operations;
539-
sb->s_qcop = &dquot_quotactl_ops;
569+
sb->s_qcop = &jfs_quotactl_ops;
540570
sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
541571
#endif
542572

@@ -840,6 +870,51 @@ static struct dquot **jfs_get_dquots(struct inode *inode)
840870
{
841871
return JFS_IP(inode)->i_dquot;
842872
}
873+
874+
static int jfs_quota_on(struct super_block *sb, int type, int format_id,
875+
const struct path *path)
876+
{
877+
int err;
878+
struct inode *inode;
879+
880+
err = dquot_quota_on(sb, type, format_id, path);
881+
if (err)
882+
return err;
883+
884+
inode = d_inode(path->dentry);
885+
inode_lock(inode);
886+
JFS_IP(inode)->mode2 |= JFS_NOATIME_FL | JFS_IMMUTABLE_FL;
887+
inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
888+
S_NOATIME | S_IMMUTABLE);
889+
inode_unlock(inode);
890+
mark_inode_dirty(inode);
891+
892+
return 0;
893+
}
894+
895+
static int jfs_quota_off(struct super_block *sb, int type)
896+
{
897+
struct inode *inode = sb_dqopt(sb)->files[type];
898+
int err;
899+
900+
if (!inode || !igrab(inode))
901+
goto out;
902+
903+
err = dquot_quota_off(sb, type);
904+
if (err)
905+
goto out_put;
906+
907+
inode_lock(inode);
908+
JFS_IP(inode)->mode2 &= ~(JFS_NOATIME_FL | JFS_IMMUTABLE_FL);
909+
inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
910+
inode_unlock(inode);
911+
mark_inode_dirty(inode);
912+
out_put:
913+
iput(inode);
914+
return err;
915+
out:
916+
return dquot_quota_off(sb, type);
917+
}
843918
#endif
844919

845920
static const struct super_operations jfs_super_operations = {

0 commit comments

Comments
 (0)