f2fs: support F2FS_IOC_FS{GET,SET}XATTR
Subsystems (2)
Chao Yu
maintainerPATCH RESEND 5/6 f2fs: support F2FS_IOC_FS{GET,SET}XATTR
From: Chao Yu <[email protected]>
This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface support for f2fs. The interface is kept consistent with the one of ext4/xfs.
--- fs/f2fs/f2fs.h | 3 + fs/f2fs/file.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 239 insertions(+), 28 deletions(-)
fs/f2fs/f2fs.h +3 -0
@@ -338,6 +338,9 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,#define F2FS_IOC32_GETVERSION FS_IOC32_GETVERSION#endif +#define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR +#define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR +struct f2fs_gc_range {u32 sync;u64 start;
fs/f2fs/file.c +236 -28
308 lines not on this page · raw message
Signature · 1 line
2.13.0.90.g1eb437020
Chao Yu
maintainerPATCH RESEND 6/6 f2fs: introduce f2fs_statfs_project
From: Chao Yu <[email protected]>
This patch introduces f2fs_statfs_project, it enables to show usage status of directory tree which is limited with project quota.
--- fs/f2fs/super.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
fs/f2fs/super.c +48 -0
@@ -705,6 +705,48 @@ static int f2fs_unfreeze(struct super_block *sb)return 0 ; } +#ifdef CONFIG_QUOTA +static int f2fs_statfs_project (struct super_block *sb, +kprojid_t projid,struct kstatfs *buf) +{ +struct kqid qid; +struct dquot *dquot; +u64 limit; +u64 curblock; + + qid =make_kqid_projid (projid); + dquot =dqget (sb, qid); +if (IS_ERR (dquot)) +return PTR_ERR (dquot); +spin_lock (&dq_data_lock); + + limit = (dquot->dq_dqb.dqb_bsoftlimit ? + dquot->dq_dqb.dqb_bsoftlimit : + dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits; +if (limit && buf->f_blocks > limit) { + curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits; + buf->f_blocks = limit; + buf->f_bfree = buf->f_bavail = + (buf->f_blocks > curblock) ? + (buf->f_blocks - curblock) :0 ; + } + + limit = dquot->dq_dqb.dqb_isoftlimit ? + dquot->dq_dqb.dqb_isoftlimit : + dquot->dq_dqb.dqb_ihardlimit; +if (limit && buf->f_files > limit) { + buf->f_files = limit; + buf->f_ffree = + (buf->f_files > dquot->dq_dqb.dqb_curinodes) ? + (buf->f_files - dquot->dq_dqb.dqb_curinodes) :0 ; + } + +spin_unlock (&dq_data_lock); +dqput (dquot); +return 0 ; +} +#endif +static int f2fs_statfs (struct dentry *dentry,struct kstatfs *buf) {struct super_block *sb = dentry->d_sb;
@@ -740,6 +782,12 @@ static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_fsid.val[0 ] = (u32 )id; buf->f_fsid.val[1 ] = (u32)(id >>32 ); +#ifdef CONFIG_QUOTA +if (is_inode_flag_set (dentry->d_inode,FI_PROJ_INHERIT ) && +sb_has_quota_limits_enabled (sb,PRJQUOTA )) { +f2fs_statfs_project (sb,F2FS_I (dentry->d_inode)->i_projid, buf); + } +#endif return 0 ; }
Signature · 1 line
2.13.0.90.g1eb437020
Chao Yu
maintainerPATCH RESEND 1/1 f2fs: support journelled quota
In reply to Chao YuFrom: Chao Yu <[email protected]>
This patch supports to enable f2fs to accept quota information through mount option:
- {usr,grp,prj}jquota=<quota file path>
- jqfmt=<quota type>
Then, in ->mount flow, we can recover quota file during log replaying, by this, journelled quota can be supported.
--- Documentation/filesystems/f2fs.txt | 9 ++ fs/f2fs/f2fs.h | 7 + fs/f2fs/recovery.c | 25 +++- fs/f2fs/super.c | 284 +++++++++++++++++++++++++++++++++++++ 4 files changed, 322 insertions(+), 3 deletions(-)
Documentation/filesystems/f2fs.txt +9 -0
@@ -165,6 +165,15 @@ io_bits=%u Set the bit size of write IO requests. It should be set usrquota Enable plain user disk quota accounting. grpquota Enable plain group disk quota accounting. prjquota Enable plain project quota accounting. +usrjquota=<file> Appoint specified file and type during mount, so that quota +grpjquota=<file> information can be properly updated during recovery flow, +prjjquota=<file> <quota file>: must be in root directory; +jqfmt=<quota type> <quota type>: [vfsold,vfsv0,vfsv1]. +offusrjquota Turn off user journelled quota. +offgrpjquota Turn off group journelled quota. +offprjjquota Turn off project journelled quota. +quota Enable plain user disk quota accounting. +noquota Disable all plain disk quota option. ================================================================================ DEBUGFS ENTRIES
fs/f2fs/f2fs.h +7 -0
@@ -92,6 +92,7 @@ extern char *fault_name[FAULT_MAX];#define F2FS_MOUNT_USRQUOTA 0x00080000#define F2FS_MOUNT_GRPQUOTA 0x00100000#define F2FS_MOUNT_PRJQUOTA 0x00200000 +#define F2FS_MOUNT_QUOTA 0x00400000#define clear_opt (sbi, option) ((sbi)->mount_opt.opt &= ~F2FS_MOUNT_##option)#define set_opt (sbi, option) ((sbi)->mount_opt.opt |= F2FS_MOUNT_##option)
@@ -1093,6 +1094,12 @@ struct f2fs_sb_info {#ifdef CONFIG_F2FS_FAULT_INJECTION struct f2fs_fault_info fault_info;#endif + +#ifdef CONFIG_QUOTA +/* Names of quota files with journalled quota */ +char *s_qf_names[MAXQUOTAS ]; +int s_jquota_fmt;/* Format of quota to use */ +#endif };#ifdef CONFIG_F2FS_FAULT_INJECTION
fs/f2fs/recovery.c +22 -3
@@ -69,20 +69,34 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head, }static struct fsync_inode_entry *add_fsync_inode (struct f2fs_sb_info *sbi, -struct list_head *head,nid_t ino) +struct list_head *head,nid_t ino,bool quota_inode) {struct inode *inode;struct fsync_inode_entry *entry; +int err; inode =f2fs_iget_retry (sbi->sb, ino);if (IS_ERR (inode))return ERR_CAST (inode); + err =dquot_initialize (inode); +if (err) + goto err_out; + +if (quota_inode) { + err =dquot_alloc_inode (inode); +if (err) + goto err_out; + } + entry =f2fs_kmem_cache_alloc (fsync_entry_slab,GFP_F2FS_ZERO ); entry->inode = inode;list_add_tail (&entry->list, head);return entry; +err_out: +iput (inode); +return ERR_PTR (err); }static void del_fsync_inode (struct fsync_inode_entry *entry)
@@ -107,7 +121,8 @@ static int recover_dentry(struct inode *inode, struct page *ipage, entry =get_fsync_inode (dir_list, pino);if (!entry) { - entry =add_fsync_inode (F2FS_I_SB (inode), dir_list, pino); + entry =add_fsync_inode (F2FS_I_SB (inode), dir_list, + pino, false);if (IS_ERR (entry)) { dir =ERR_CAST (entry); err =PTR_ERR (entry);
@@ -226,18 +241,22 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head, entry =get_fsync_inode (head,ino_of_node (page));if (!entry) { +bool quota_inode = false; +if (!check_only &&IS_INODE (page) &&is_dent_dnode (page)) { err =recover_inode_page (sbi, page);if (err)break ; + quota_inode = true; }/* * CP | dnode(F) | inode(DF) * For this case, we should not give up now. */ - entry =add_fsync_inode (sbi, head,ino_of_node (page)); + entry =add_fsync_inode (sbi, head,ino_of_node (page), + quota_inode);if (IS_ERR (entry)) { err =PTR_ERR (entry);if (err == -ENOENT ) {
fs/f2fs/super.c +284 -0
402 lines not on this page · raw message
Signature · 1 line
2.13.0.90.g1eb437020