[f2fs-dev] (Resend) [PATCH v2] f2fs: fix to use per-inode maxbytes in f2fs_fiemap

2021-03-08 Thread Chengguang Xu
F2FS inode may have different max size,
so change to use per-inode maxbytes.

Signed-off-by: Chengguang Xu 
---
Hi Jaegeuk, Chao

Please take this instead of previous v2 patch which has sent by mistake.

v1->v2:
- Calculate max bytes in inode lock.

 fs/f2fs/data.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7c95818639a6..b734ca023149 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1837,6 +1837,7 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
int ret = 0;
bool compr_cluster = false;
unsigned int cluster_size = F2FS_I(inode)->i_cluster_size;
+   loff_t maxbytes;
 
if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
ret = f2fs_precache_extents(inode);
@@ -1850,6 +1851,15 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
 
inode_lock(inode);
 
+   maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+   if (start > maxbytes) {
+   ret = -EFBIG;
+   goto out;
+   }
+
+   if (len > maxbytes || (maxbytes - len) < start)
+   len = maxbytes - start;
+
if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
ret = f2fs_xattr_fiemap(inode, fieinfo);
goto out;
-- 
2.27.0




___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2] f2fs: fix to use per-inode maxbytes in f2fs_fiemap

2021-03-08 Thread Chengguang Xu
F2FS inode may have different max size,
so change to use per-inode maxbytes.

Signed-off-by: Chengguang Xu 
---
v1->v2:

- Calculate max bytes in inode lock.

 fs/f2fs/data.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7c95818639a6..3cbcde4174e6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1850,6 +1850,15 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
 
inode_lock(inode);
 
+   maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+   if (start > maxbytes) {
+   ret = -EFBIG;
+   goto out;
+   }
+
+   if (len > maxbytes || (maxbytes - len) < start)
+   len = maxbytes - start;
+
if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
ret = f2fs_xattr_fiemap(inode, fieinfo);
goto out;
-- 
2.27.0




___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes in f2fs_fiemap

2021-02-25 Thread Chengguang Xu
  在 星期四, 2021-02-25 09:24:51 Chao Yu  撰写 
 > On 2021/2/23 19:50, Chengguang Xu wrote:
 > > F2FS inode may have different max size,
 > > so change to use per-inode maxbytes.
 > > 
 > > Signed-off-by: Chengguang Xu 
 > > ---
 > >   fs/f2fs/data.c | 5 +
 > >   1 file changed, 5 insertions(+)
 > > 
 > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
 > > index b9721c8f116c..b330c6a27b14 100644
 > > --- a/fs/f2fs/data.c
 > > +++ b/fs/f2fs/data.c
 > > @@ -1838,6 +1838,7 @@ int f2fs_fiemap(struct inode *inode, struct 
 > > fiemap_extent_info *fieinfo,
 > >   int ret = 0;
 > >   bool compr_cluster = false;
 > >   unsigned int cluster_size = F2FS_I(inode)->i_cluster_size;
 > > +loff_t maxbytes;
 > >   
 > >   if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
 > >   ret = f2fs_precache_extents(inode);
 > > @@ -1845,6 +1846,10 @@ int f2fs_fiemap(struct inode *inode, struct 
 > > fiemap_extent_info *fieinfo,
 > >   return ret;
 > >   }
 > >   
 > > +maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
 > > +if (len > maxbytes || (maxbytes - len) < start)
 > > +len = maxbytes - start;
 > 
 > This should be checked under inode lock, otherwise the max filesize 
 > calculation
 > can race with compress inode conversion.
 > 

Thanks for your review. There are some other places also calling 
max_file_blocks() and f2fs_compressed_file(),
so  I'm wondering  if we should add lock inside f2fs_compressed_file() to avoid 
race with compress inode conversion.

Thanks,
Chengguang


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes in f2fs_fiemap

2021-02-23 Thread Chengguang Xu
F2FS inode may have different max size,
so change to use per-inode maxbytes.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/data.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b9721c8f116c..b330c6a27b14 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1838,6 +1838,7 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
int ret = 0;
bool compr_cluster = false;
unsigned int cluster_size = F2FS_I(inode)->i_cluster_size;
+   loff_t maxbytes;
 
if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
ret = f2fs_precache_extents(inode);
@@ -1845,6 +1846,10 @@ int f2fs_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
return ret;
}
 
+   maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+   if (len > maxbytes || (maxbytes - len) < start)
+   len = maxbytes - start;
+
ret = fiemap_prep(inode, fieinfo, start, , FIEMAP_FLAG_XATTR);
if (ret)
return ret;
-- 
2.27.0




___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: fix to use per-inode maxbytes

2021-01-12 Thread Chengguang Xu
F2FS inode may have different max size, e.g. compressed file have
less blkaddr entries in all its direct-node blocks, result in being
with less max filesize. So change to use per-inode maxbytes.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/data.c  |  2 +-
 fs/f2fs/f2fs.h  |  2 +-
 fs/f2fs/file.c  |  9 ++---
 fs/f2fs/super.c | 12 
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index aa34d62..56badcb 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3831,7 +3831,7 @@ static sector_t f2fs_bmap(struct address_space *mapping, 
sector_t block)
filemap_write_and_wait(mapping);
 
/* Block number less than F2FS MAX BLOCKS */
-   if (unlikely(block >= F2FS_I_SB(inode)->max_file_blocks))
+   if (unlikely(block >= max_file_blocks(inode)))
goto out;
 
if (f2fs_compressed_file(inode)) {
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index bb11759..4328b98 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1444,7 +1444,6 @@ struct f2fs_sb_info {
unsigned int total_sections;/* total section count */
unsigned int total_node_count;  /* total node block count */
unsigned int total_valid_node_count;/* valid node block count */
-   loff_t max_file_blocks; /* max block index of file */
int dir_level;  /* directory level */
int readdir_ra; /* readahead inode in readdir */
u64 max_io_bytes;   /* max io bytes to merge IOs */
@@ -3232,6 +3231,7 @@ static inline int f2fs_add_link(struct dentry *dentry, 
struct inode *inode)
 void f2fs_inode_synced(struct inode *inode);
 int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly);
 int f2fs_quota_sync(struct super_block *sb, int type);
+loff_t max_file_blocks(struct inode *inode);
 void f2fs_quota_off_umount(struct super_block *sb);
 int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover);
 int f2fs_sync_fs(struct super_block *sb, int sync);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f585545..5cddd23 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -483,6 +483,9 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, 
int whence)
struct inode *inode = file->f_mapping->host;
loff_t maxbytes = inode->i_sb->s_maxbytes;
 
+   if (f2fs_compressed_file(inode))
+   maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS;
+
switch (whence) {
case SEEK_SET:
case SEEK_CUR:
@@ -667,7 +670,7 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, 
bool lock)
 
free_from = (pgoff_t)F2FS_BLK_ALIGN(from);
 
-   if (free_from >= sbi->max_file_blocks)
+   if (free_from >= max_file_blocks(inode))
goto free_partial;
 
if (lock)
@@ -2730,7 +2733,7 @@ static int f2fs_ioc_defragment(struct file *filp, 
unsigned long arg)
return -EINVAL;
 
if (unlikely((range.start + range.len) >> PAGE_SHIFT >
-   sbi->max_file_blocks))
+   max_file_blocks(inode)))
return -EINVAL;
 
err = mnt_want_write_file(filp);
@@ -3293,7 +3296,7 @@ int f2fs_precache_extents(struct inode *inode)
map.m_next_extent = _next_extent;
map.m_seg_type = NO_CHECK_TYPE;
map.m_may_create = false;
-   end = F2FS_I_SB(inode)->max_file_blocks;
+   end = max_file_blocks(inode);
 
while (map.m_lblk < end) {
map.m_len = end - map.m_lblk;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index b4a07fe..9132c39 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2638,10 +2638,10 @@ static struct dentry *f2fs_fh_to_parent(struct 
super_block *sb, struct fid *fid,
.get_parent = f2fs_get_parent,
 };
 
-static loff_t max_file_blocks(void)
+loff_t max_file_blocks(struct inode *inode)
 {
loff_t result = 0;
-   loff_t leaf_count = DEF_ADDRS_PER_BLOCK;
+   loff_t leaf_count;
 
/*
 * note: previously, result is equal to (DEF_ADDRS_PER_INODE -
@@ -2650,6 +2650,11 @@ static loff_t max_file_blocks(void)
 * result as zero.
 */
 
+   if (inode && f2fs_compressed_file(inode))
+   leaf_count = ADDRS_PER_BLOCK(inode);
+   else
+   leaf_count = DEF_ADDRS_PER_BLOCK;
+
/* two direct node blocks */
result += (leaf_count * 2);
 
@@ -3533,8 +3538,7 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
if (err)
goto free_options;
 
-   sbi->max_file_blocks = max_file_blocks();
-   sb->s_maxbytes = sbi->max_file_blocks <<
+   sb->s_maxbytes = max_file_blocks(NULL) <<
le32_to

Re: [f2fs-dev] [RFC PATCH] f2fs: using generic_file_llseek() instead of generic_file_llseek_size()

2021-01-11 Thread Chengguang Xu
  在 星期一, 2021-01-11 15:35:07 Chao Yu  撰写 
 > On 2021/1/10 19:48, Chengguang Xu wrote:
 > > generic_file_llseek_size() is used for filesystems that have
 > > a custom maximum size and a custom EOF position. so it's better
 > > to replace it using generic_file_llseek().
 > 
 > F2FS inode may have different max size, e.g. compressed file have
 > less blkaddr entries in all its direct-node blocks, result in being
 > with less max filesize.
 > 
 > I guess we should consider that when checking boundary with s_maxbytes,
 > so how about using below patch instead:
 > 
 > Subject: [PATCH] f2fs: fix to use per-inode maxbytes

Hi Chao,

Thanks for your review and suggestion. It looks a proper fix.
Would you mind me sending revised patch follow your suggestion?

Thanks


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [RFC PATCH] f2fs: using generic_file_llseek() instead of generic_file_llseek_size()

2021-01-10 Thread Chengguang Xu
generic_file_llseek_size() is used for filesystems that have
a custom maximum size and a custom EOF position. so it's better
to replace it using generic_file_llseek().

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/file.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f585545..2ca22ea 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -480,15 +480,11 @@ static loff_t f2fs_seek_block(struct file *file, loff_t 
offset, int whence)
 
 static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
 {
-   struct inode *inode = file->f_mapping->host;
-   loff_t maxbytes = inode->i_sb->s_maxbytes;
-
switch (whence) {
case SEEK_SET:
case SEEK_CUR:
case SEEK_END:
-   return generic_file_llseek_size(file, offset, whence,
-   maxbytes, i_size_read(inode));
+   return generic_file_llseek(file, offset, whence);
case SEEK_DATA:
case SEEK_HOLE:
if (offset < 0)
-- 
1.8.3.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: code cleanup by removing unnecessary check

2020-10-12 Thread Chengguang Xu
f2fs_seek_block() is only used for regular file,
so don't have to check inline dentry in it.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/file.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 8a422400e824..048c89517001 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -429,9 +429,8 @@ static loff_t f2fs_seek_block(struct file *file, loff_t 
offset, int whence)
goto fail;
 
/* handle inline data case */
-   if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode)) {
-   if (whence == SEEK_HOLE)
-   data_ofs = isize;
+   if (f2fs_has_inline_data(inode) && whence == SEEK_HOLE) {
+   data_ofs = isize;
goto found;
}
 
-- 
2.26.2




___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: code cleanup by removing ifdef macro surrounding

2020-05-26 Thread Chengguang Xu
Define f2fs_listxattr and to NULL when CONFIG_F2FS_FS_XATTR is not
enabled, then we can remove many ugly ifdef macros in the code.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/file.c  | 2 --
 fs/f2fs/namei.c | 8 
 fs/f2fs/xattr.h | 6 +-
 3 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 6ab8f621a3c5..330397a2fc12 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -968,9 +968,7 @@ const struct inode_operations f2fs_file_inode_operations = {
.setattr= f2fs_setattr,
.get_acl= f2fs_get_acl,
.set_acl= f2fs_set_acl,
-#ifdef CONFIG_F2FS_FS_XATTR
.listxattr  = f2fs_listxattr,
-#endif
.fiemap = f2fs_fiemap,
 };
 
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index f54119da2217..2091d17ff26b 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1287,9 +1287,7 @@ const struct inode_operations 
f2fs_encrypted_symlink_inode_operations = {
.get_link   = f2fs_encrypted_get_link,
.getattr= f2fs_getattr,
.setattr= f2fs_setattr,
-#ifdef CONFIG_F2FS_FS_XATTR
.listxattr  = f2fs_listxattr,
-#endif
 };
 
 const struct inode_operations f2fs_dir_inode_operations = {
@@ -1307,9 +1305,7 @@ const struct inode_operations f2fs_dir_inode_operations = 
{
.setattr= f2fs_setattr,
.get_acl= f2fs_get_acl,
.set_acl= f2fs_set_acl,
-#ifdef CONFIG_F2FS_FS_XATTR
.listxattr  = f2fs_listxattr,
-#endif
.fiemap = f2fs_fiemap,
 };
 
@@ -1317,9 +1313,7 @@ const struct inode_operations 
f2fs_symlink_inode_operations = {
.get_link   = f2fs_get_link,
.getattr= f2fs_getattr,
.setattr= f2fs_setattr,
-#ifdef CONFIG_F2FS_FS_XATTR
.listxattr  = f2fs_listxattr,
-#endif
 };
 
 const struct inode_operations f2fs_special_inode_operations = {
@@ -1327,7 +1321,5 @@ const struct inode_operations 
f2fs_special_inode_operations = {
.setattr= f2fs_setattr,
.get_acl= f2fs_get_acl,
.set_acl= f2fs_set_acl,
-#ifdef CONFIG_F2FS_FS_XATTR
.listxattr  = f2fs_listxattr,
-#endif
 };
diff --git a/fs/f2fs/xattr.h b/fs/f2fs/xattr.h
index 938fcd20565d..d43c0761302d 100644
--- a/fs/f2fs/xattr.h
+++ b/fs/f2fs/xattr.h
@@ -136,6 +136,7 @@ extern void f2fs_destroy_xattr_caches(struct f2fs_sb_info 
*);
 #else
 
 #define f2fs_xattr_handlersNULL
+#define f2fs_listxattr NULL
 static inline int f2fs_setxattr(struct inode *inode, int index,
const char *name, const void *value, size_t size,
struct page *page, int flags)
@@ -148,11 +149,6 @@ static inline int f2fs_getxattr(struct inode *inode, int 
index,
 {
return -EOPNOTSUPP;
 }
-static inline ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer,
-   size_t buffer_size)
-{
-   return -EOPNOTSUPP;
-}
 static inline int f2fs_init_xattr_caches(struct f2fs_sb_info *sbi) { return 0; 
}
 static inline void f2fs_destroy_xattr_caches(struct f2fs_sb_info *sbi) { }
 #endif
-- 
2.20.1




___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 1/2] f2fs: fix miscounted block limit in f2fs_statfs_project()

2020-01-04 Thread Chengguang Xu
statfs calculates Total/Used/Avail disk space in block unit,
so we should translate soft/hard prjquota limit to block unit
as well.

Below testing result shows the block/inode numbers of
Total/Used/Avail from df command are all correct afer
applying this patch.

[root@localhost quota-tools]\# ./repquota -P /dev/sdb1
*** Report for project quotas on device /dev/sdb1
Block grace time: 7days; Inode grace time: 7days
  Block limitsFile limits
Project   used softhard  grace  used  soft  hard  grace
---
\#0   --   4   0   0 1 0 0
\#101 --   0   0   0 2 0 0
\#102 --   0   10240   0 210 0
\#103 --   0   0   20480 2 020
\#104 --   0   10240   20480 21020
\#105 --   0   20480   10240 22010

[root@localhost sdb1]\# lsattr -p t{1,2,3,4,5}
  101 N-- t1/a1
  102 N-- t2/a2
  103 N-- t3/a3
  104 N-- t4/a4
  105 N-- t5/a5

[root@localhost sdb1]\# df -hi t{1,2,3,4,5}
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sdb12.4M21  2.4M1% /mnt/sdb1
/dev/sdb1  10 2 8   20% /mnt/sdb1
/dev/sdb1  20 218   10% /mnt/sdb1
/dev/sdb1  10 2 8   20% /mnt/sdb1
/dev/sdb1  10 2 8   20% /mnt/sdb1

[root@localhost sdb1]\# df -h t{1,2,3,4,5}
Filesystem  Size  Used Avail Use% Mounted on
/dev/sdb110G  489M  9.6G   5% /mnt/sdb1
/dev/sdb110M 0   10M   0% /mnt/sdb1
/dev/sdb120M 0   20M   0% /mnt/sdb1
/dev/sdb110M 0   10M   0% /mnt/sdb1
/dev/sdb110M 0   10M   0% /mnt/sdb1

Fixes: 909110c060f2 ("f2fs: choose hardlimit when softlimit is larger than 
hardlimit in f2fs_statfs_project()")
Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 5111e1ffe58a..78efd0e76174 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1219,6 +1219,8 @@ static int f2fs_statfs_project(struct super_block *sb,
if (dquot->dq_dqb.dqb_bhardlimit &&
(!limit || dquot->dq_dqb.dqb_bhardlimit < limit))
limit = dquot->dq_dqb.dqb_bhardlimit;
+   if (limit)
+   limit >>= sb->s_blocksize_bits;
 
if (limit && buf->f_blocks > limit) {
curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
-- 
2.21.1





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 2/2] f2fs: code cleanup for f2fs_statfs_project()

2020-01-04 Thread Chengguang Xu
Calling min_not_zero() to simplify complicated prjquota
limit comparison in f2fs_statfs_project().

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 78efd0e76174..ac01c3f8863d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1213,12 +1213,8 @@ static int f2fs_statfs_project(struct super_block *sb,
return PTR_ERR(dquot);
spin_lock(>dq_dqb_lock);
 
-   limit = 0;
-   if (dquot->dq_dqb.dqb_bsoftlimit)
-   limit = dquot->dq_dqb.dqb_bsoftlimit;
-   if (dquot->dq_dqb.dqb_bhardlimit &&
-   (!limit || dquot->dq_dqb.dqb_bhardlimit < limit))
-   limit = dquot->dq_dqb.dqb_bhardlimit;
+   limit = min_not_zero(dquot->dq_dqb.dqb_bsoftlimit,
+   dquot->dq_dqb.dqb_bhardlimit);
if (limit)
limit >>= sb->s_blocksize_bits;
 
@@ -1230,12 +1226,8 @@ static int f2fs_statfs_project(struct super_block *sb,
 (buf->f_blocks - curblock) : 0;
}
 
-   limit = 0;
-   if (dquot->dq_dqb.dqb_isoftlimit)
-   limit = dquot->dq_dqb.dqb_isoftlimit;
-   if (dquot->dq_dqb.dqb_ihardlimit &&
-   (!limit || dquot->dq_dqb.dqb_ihardlimit < limit))
-   limit = dquot->dq_dqb.dqb_ihardlimit;
+   limit = min_not_zero(dquot->dq_dqb.dqb_isoftlimit,
+   dquot->dq_dqb.dqb_ihardlimit);
 
if (limit && buf->f_files > limit) {
buf->f_files = limit;
-- 
2.21.1





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2] f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()

2019-11-24 Thread Chengguang Xu
Setting softlimit larger than hardlimit seems meaningless
for disk quota but currently it is allowed. In this case,
there may be a bit of comfusion for users when they run
df comamnd to directory which has project quota.

For example, we set 20M softlimit and 10M hardlimit of
block usage limit for project quota of test_dir(project id 123).

[root@hades f2fs]# repquota -P -a
*** Report for project quotas on device /dev/nvme0n1p8
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
Project used soft hard grace used soft hard grace
--
0 -- 4 0 0 1 0 0
123 +- 10248 20480 10240 2 0 0

The result of df command as below:

[root@hades f2fs]# df -h /mnt/f2fs/test
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p8 20M 11M 10M 51% /mnt/f2fs

Even though it looks like there is another 10M free space to use,
if we write new data to diretory test(inherit project id),
the write will fail with errno(-EDQUOT).

After this patch, the df result looks like below.

[root@hades f2fs]# df -h /mnt/f2fs/test
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p8 10M 10M 0 100% /mnt/f2fs

Signed-off-by: Chengguang Xu 
---
v1->v2:
- Remove unnecessary condition check.
- Fix coding sytle.

 fs/f2fs/super.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1443cee15863..a2af155567b8 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1213,9 +1213,13 @@ static int f2fs_statfs_project(struct super_block *sb,
return PTR_ERR(dquot);
spin_lock(>dq_dqb_lock);
 
-   limit = (dquot->dq_dqb.dqb_bsoftlimit ?
-dquot->dq_dqb.dqb_bsoftlimit :
-dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits;
+   limit = 0;
+   if (dquot->dq_dqb.dqb_bsoftlimit)
+   limit = dquot->dq_dqb.dqb_bsoftlimit;
+   if (dquot->dq_dqb.dqb_bhardlimit &&
+   (!limit || dquot->dq_dqb.dqb_bhardlimit < limit))
+   limit = dquot->dq_dqb.dqb_bhardlimit;
+
if (limit && buf->f_blocks > limit) {
curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
buf->f_blocks = limit;
@@ -1224,9 +1228,13 @@ static int f2fs_statfs_project(struct super_block *sb,
 (buf->f_blocks - curblock) : 0;
}
 
-   limit = dquot->dq_dqb.dqb_isoftlimit ?
-   dquot->dq_dqb.dqb_isoftlimit :
-   dquot->dq_dqb.dqb_ihardlimit;
+   limit = 0;
+   if (dquot->dq_dqb.dqb_isoftlimit)
+   limit = dquot->dq_dqb.dqb_isoftlimit;
+   if (dquot->dq_dqb.dqb_ihardlimit &&
+   (!limit || dquot->dq_dqb.dqb_ihardlimit < limit))
+   limit = dquot->dq_dqb.dqb_ihardlimit;
+
if (limit && buf->f_files > limit) {
buf->f_files = limit;
buf->f_ffree =
-- 
2.20.1





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [RFC PATCH 1/3] ext4: show prjquota info on statfs for a file

2019-11-17 Thread Chengguang Xu
Currently we replace filesystem statistics using prjquota info
on statfs when specified directory has project id inherit flag.
However, statfs on a file(accurately non-dir) which is under the
project quota dir(with inherit flag) still shows whole filesystem
statistics. In container use case, it will give container user
inconsistent experience and cause confusion about available free
space.

Detail info like below:
We use project quota to limit disk space usage for a container
and run df command inside container.

Run df on a directory:

[root /]# df -h /etc/
Filesystem  Size  Used Avail Use% Mounted on
kataShared  1.0G   13M 1012M   2% /

Run df on a file:

[root /]# df -h /etc/exports
Filesystem  Size  Used Avail Use% Mounted on
kataShared  1.5T  778M  1.5T   1% /

Signed-off-by: Chengguang Xu 
---
 fs/ext4/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index dd654e53ba3d..3fba22b54f5c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5607,7 +5607,8 @@ static int ext4_statfs(struct dentry *dentry, struct 
kstatfs *buf)
buf->f_fsid.val[1] = (fsid >> 32) & 0xUL;
 
 #ifdef CONFIG_QUOTA
-   if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) &&
+   if ((ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) ||
+!S_ISDIR(dentry->d_inode->i_mode)) &&
sb_has_quota_limits_enabled(sb, PRJQUOTA))
ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf);
 #endif
-- 
2.20.1





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [RFC PATCH 2/3] f2fs: show prjquota info on statfs for a file

2019-11-17 Thread Chengguang Xu
Currently we replace filesystem statistics using prjquota info
on statfs when specified directory has project id inherit flag.
However, statfs on a file(accurately non-dir) which is under the
project quota dir(with inherit flag) still shows whole filesystem
statistics. In container use case, it will give container user
inconsistent experience and cause confusion about available free
space.

Detail info like below:
We use project quota to limit disk space usage for a container
and run df command inside container.

Run df on a directory:

[root /]# df -h /etc/
Filesystem  Size  Used Avail Use% Mounted on
kataShared  1.0G   13M 1012M   2% /

Run df on a file:

[root /]# df -h /etc/exports
Filesystem  Size  Used Avail Use% Mounted on
kataShared  1.5T  778M  1.5T   1% /

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1443cee15863..c5b9a92d606b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1287,8 +1287,9 @@ static int f2fs_statfs(struct dentry *dentry, struct 
kstatfs *buf)
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)) {
+   if ((is_inode_flag_set(dentry->d_inode, FI_PROJ_INHERIT) ||
+!S_ISDIR(dentry->d_inode->i_mode)) &&
+   sb_has_quota_limits_enabled(sb, PRJQUOTA)) {
f2fs_statfs_project(sb, F2FS_I(dentry->d_inode)->i_projid, buf);
}
 #endif
-- 
2.20.1





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [RFC PATCH 3/3] xfs: show prjquota info on statfs for a file

2019-11-17 Thread Chengguang Xu
Currently we replace filesystem statistics using prjquota info
on statfs when specified directory has project id inherit flag.
However, statfs on a file(accurately non-dir) which is under the
project quota dir(with inherit flag) still shows whole filesystem
statistics. In container use case, it will give container user
inconsistent experience and cause confusion about available free
space.

Detail info like below:
We use project quota to limit disk space usage for a container
and run df command inside container.

Run df on a directory:

[root /]# df -h /etc/
Filesystem  Size  Used Avail Use% Mounted on
kataShared  1.0G   13M 1012M   2% /

Run df on a file:

[root /]# df -h /etc/exports
Filesystem  Size  Used Avail Use% Mounted on
kataShared  1.5T  778M  1.5T   1% /

Signed-off-by: Chengguang Xu 
---
 fs/xfs/xfs_super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8d1df9f8be07..9f4d9e86572a 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1125,7 +1125,8 @@ xfs_fs_statfs(
statp->f_ffree = max_t(int64_t, ffree, 0);
 
 
-   if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+   if (((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) ||
+!S_ISDIR(dentry->d_inode->i_mode)) &&
((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
  (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
xfs_qm_statvfs(ip, statp);
-- 
2.20.1





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: fix a comment in f2fs_shrink_count()

2019-09-27 Thread Chengguang Xu via Linux-f2fs-devel
Fix a mismatched comment in f2fs_shrink_count().

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/shrinker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index a467aca29cfe..d66de5999a26 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -58,7 +58,7 @@ unsigned long f2fs_shrink_count(struct shrinker *shrink,
/* count extent cache entries */
count += __count_extent_cache(sbi);
 
-   /* shrink clean nat cache entries */
+   /* count clean nat cache entries */
count += __count_nat_entries(sbi);
 
/* count free nids cache entries */
-- 
2.21.0





___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: remove redundant check in f2fs_file_write_iter()

2019-04-22 Thread Chengguang Xu
We have already checked flag IOCB_DIRECT in the sanity
check of flag IOCB_NOWAIT, so don't have to check it
again here.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/file.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 5742ab8b57dc..43b6a0b08497 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3056,18 +3056,15 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, 
struct iov_iter *from)
if (iov_iter_fault_in_readable(from, iov_iter_count(from)))
set_inode_flag(inode, FI_NO_PREALLOC);

-   if ((iocb->ki_flags & IOCB_NOWAIT) &&
-   (iocb->ki_flags & IOCB_DIRECT)) {
-   if (!f2fs_overwrite_io(inode, iocb->ki_pos,
-   iov_iter_count(from)) ||
-   f2fs_has_inline_data(inode) ||
-   f2fs_force_buffered_io(inode,
-   iocb, from)) {
-   clear_inode_flag(inode,
-   FI_NO_PREALLOC);
-   inode_unlock(inode);
-   return -EAGAIN;
-   }
+   if (iocb->ki_flags & IOCB_NOWAIT) {
+   if (!f2fs_overwrite_io(inode, iocb->ki_pos,
+   iov_iter_count(from)) ||
+   f2fs_has_inline_data(inode) ||
+   f2fs_force_buffered_io(inode, iocb, from)) {
+   clear_inode_flag(inode, FI_NO_PREALLOC);
+   inode_unlock(inode);
+   return -EAGAIN;
+   }

} else {
preallocated = true;
--
2.20.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: jump to label 'free_node_inode' when failing from d_make_root()

2019-01-22 Thread Chengguang Xu
When sb->s_root is NULL dput() will do nothing,
so jump to label 'free_node_inode' instead of lable
'free_root_inode' when failing from d_make_root().

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index c46a1d4318d4..d92d4508f262 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3288,7 +3288,7 @@ static int f2fs_fill_super(struct super_block *sb, void 
*data, int silent)
sb->s_root = d_make_root(root); /* allocate root dentry */
if (!sb->s_root) {
err = -ENOMEM;
-   goto free_root_inode;
+   goto free_node_inode;
}
 
err = f2fs_register_sysfs(sbi);
-- 
2.20.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: change error code to -ENOMEM from -EINVAL

2019-01-01 Thread Chengguang Xu
The error case of failing allocating memory should
return -ENOMEM.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index af58b2cc21b8..913274365f93 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -269,7 +269,7 @@ static int f2fs_set_qf_name(struct super_block *sb, int 
qtype,
if (!qname) {
f2fs_msg(sb, KERN_ERR,
"Not enough memory for storing quotafile name");
-   return -EINVAL;
+   return -ENOMEM;
}
if (F2FS_OPTION(sbi).s_qf_names[qtype]) {
if (strcmp(F2FS_OPTION(sbi).s_qf_names[qtype], qname) == 0)
-- 
2.17.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: remove default option setting in remount

2018-10-17 Thread Chengguang Xu
On 2018/9/25 at 3:41 PM, Chao Yu wrote:

> On 2018/9/22 22:40, cgxu519 wrote:
> > On 09/20/2018 02:29 PM, Chao Yu wrote:
> >> On 2018/9/20 7:54, cgxu519 wrote:
> >>> On 9/19/18 10:02 PM, Chao Yu wrote:
> >>>> On 2018/9/18 21:47, cgxu519 wrote:
> >>>>> On 09/18/2018 09:20 PM, Chao Yu wrote:
> >>>>>> On 2018/9/18 14:23, Chengguang Xu wrote:
> >>>>>>> Currently we set default value to options before parsing remount 
> >>>>>>> options,
> >>>>>>> it will cause unexpected change of options which were specified in 
> >>>>>>> first
> >>>>>>> mount.
> >>>>>> Can you check below commit? It looks w/o it we may lose default option 
> >>>>>> after
> >>>>>> remount.
> >>>>>>
> >>>>>> 498c5e9fcd10 ("f2fs: add default mount options to remount")
> >>>>> Hi Chao,
> >>>> Hi Chengguang,
> >>>>
> >>>>> It looks like there was a bug in remount at that time, but I think the 
> >>>>> fix above
> >>>>> is not correct.
> >>>>>
> >>>>> from the patch '498c5e9fcd10', I think it was caused by clearing
> >>>>> sbi->mount_opt.opt before
> >>>>>
> >>>>> parsing. I think remount should not change the options which were 
> >>>>> specified by
> >>>>> user in
> >>>>>
> >>>>> previous mount unless user specifies in remount.
> >>>> Can you check description in manual of mount.
> >>>>
> >>>> IIRC, old mount option will be record into /etc/mtab or /proc/mounts (for
> >>>> adapting namespace feature), with command of "mount -o remount,rw  
> >>>> /dir", old
> >>>> mount options can be loaded from above config file, and merge them with 
> >>>> new
> >>>> specified options.
> >>>>
> >>>> Even we kill old mount options by call default_options() in ->remount, 
> >>>> user's
> >>>> old mount option can still be set through parameters.
> >>> Please let me show you different behaviors before/after this patch.
> >>>
> >>>
> >>> [root@x201 cgxu]# uname -a
> >>> Linux x201 4.19.0-rc2+ #51 SMP Wed Sep 19 22:41:20 CST 2018 x86_64
> >>> x86_64 x86_64 GNU/Linux
> >>>
> >>>
> >>> Before:
> >>>
> >>> [root@x201 cgxu]# mount -o fsync_mode=strict /dev/mapper/test-test1
> >>> /mnt/test/test1
> >>> [root@x201 cgxu]# mount | grep test1
> >>> /dev/mapper/test-test1 on /mnt/test/test1 type f2fs
> >>> (rw,relatime,lazytime,background_gc=on,discard,no_heap,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=reuse,fsync_mode=strict)
> >>>
> >>> [root@x201 cgxu]# mount -o remount,background_gc=sync
> >>> /dev/mapper/test-test1 /mnt/test/test1
> >>> [root@x201 cgxu]# mount | grep test1
> >>> /dev/mapper/test-test1 on /mnt/test/test1 type f2fs
> >>> (rw,relatime,background_gc=sync,discard,no_heap,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,extent_cache,mode=adaptive,active_logs=6,alloc_mode=default,fsync_mode=posix)
> >>>
> >>>
> >>> I only changed background_gc in ->remount, but fsync_mode is implicitly
> >>> set to default value 'posix'.
> >> IMO, the resul is as expected, let's referenced description in manual of 
> >> mount:
> >>
> >>The  remount  functionality  follows the standard way how 
> >> the
> >> mount command works with options from fstab. It means the mount command
> >> doesn't read fstab (or mtab) only when a device and
> >>dir are fully specified.
> >>
> >>mount -o remount,rw /dev/foo /dir
> >>
> >>After this call all old mount options are replaced and
> >> arbitrary stuff from fstab is ignored, except the loop= option which is
> >> internally generated and maintained by the mount command.
> >>
> >>mount -o remount,rw  /dir
> >>
> >>After this call mount reads fstab (or mtab) and merges these
> >> options with options from command line ( -o ).
> >>
> >>
> >> So if you want to keep old mount option, you should use:
> >>
> >> mount -o remount,background_gc=sync /mnt/test/test1
> >>
> >> instead of
> >>
> >> mount -o remount,background_gc=sync /dev/mapper/test-test1 /mnt/test/test1
> > 
> > I get your point about how mount command organizes options ,
> > but it seems other filesystem do not initialize mount option in remount.
> > What do you think for that? and if we keep initialization in f2fs,
> > shouldn't we set default value to all mount options for remount?
> 
> I'm okay with this change to keep line with other filesystems.

Hi Chao

Do you agree this patch without change of commit log?

Thanks,
Chengguang



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 1/2] f2fs: remove QUOTA flag setting in f2fs_set_qf_name()

2018-09-27 Thread Chengguang Xu
Mount flag QUOTA is the same as flag USRQUOTA in f2fs, so should not
set flag QUOTA in f2fs_set_qf_name().

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 896b885f504e..e2abd45c2cdd 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -286,7 +286,6 @@ static int f2fs_set_qf_name(struct super_block *sb, int 
qtype,
goto errout;
}
F2FS_OPTION(sbi).s_qf_names[qtype] = qname;
-   set_opt(sbi, QUOTA);
return 0;
 errout:
kfree(qname);
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 2/2] f2fs: remove unnecessary mount optino flag 'QUOTA'

2018-09-27 Thread Chengguang Xu
Code cleanup by removing unnecessary mount option
flag 'QUOTA'.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/f2fs.h  | 1 -
 fs/f2fs/super.c | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index abf925664d9c..58d3e40ee46c 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -97,7 +97,6 @@ extern char *f2fs_fault_name[FAULT_MAX];
 #define F2FS_MOUNT_USRQUOTA0x0008
 #define F2FS_MOUNT_GRPQUOTA0x0010
 #define F2FS_MOUNT_PRJQUOTA0x0020
-#define F2FS_MOUNT_QUOTA   0x0040
 #define F2FS_MOUNT_INLINE_XATTR_SIZE   0x0080
 #define F2FS_MOUNT_RESERVE_ROOT0x0100
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e2abd45c2cdd..74eb63e8a2fd 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -680,7 +680,6 @@ static int parse_options(struct super_block *sb, char 
*options)
F2FS_OPTION(sbi).s_jquota_fmt = QFMT_VFS_V1;
break;
case Opt_noquota:
-   clear_opt(sbi, QUOTA);
clear_opt(sbi, USRQUOTA);
clear_opt(sbi, GRPQUOTA);
clear_opt(sbi, PRJQUOTA);
@@ -1345,8 +1344,6 @@ static int f2fs_show_options(struct seq_file *seq, struct 
dentry *root)
}
 #endif
 #ifdef CONFIG_QUOTA
-   if (test_opt(sbi, QUOTA))
-   seq_puts(seq, ",quota");
if (test_opt(sbi, USRQUOTA))
seq_puts(seq, ",usrquota");
if (test_opt(sbi, GRPQUOTA))
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: fix remount problem of option io_bits

2018-09-22 Thread Chengguang Xu
Currently we show mount option "io_bits=%u" as "io_size=%uKB",
it will cause option parsing problem(unrecognized mount option)
in remount.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 896b885f504e..8c96c4e9ee8d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1336,7 +1336,8 @@ static int f2fs_show_options(struct seq_file *seq, struct 
dentry *root)
from_kgid_munged(_user_ns,
F2FS_OPTION(sbi).s_resgid));
if (F2FS_IO_SIZE_BITS(sbi))
-   seq_printf(seq, ",io_size=%uKB", F2FS_IO_SIZE_KB(sbi));
+   seq_printf(seq, ",io_bits=%u",
+   F2FS_OPTION(sbi).write_io_size_bits);
 #ifdef CONFIG_F2FS_FAULT_INJECTION
if (test_opt(sbi, FAULT_INJECTION)) {
seq_printf(seq, ",fault_injection=%u",
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: remove default option setting in remount

2018-09-18 Thread Chengguang Xu
Currently we set default value to options before parsing remount options,
it will cause unexpected change of options which were specified in first
mount.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 00d512cd4bf2..89ea19466e80 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1499,8 +1499,6 @@ static int f2fs_remount(struct super_block *sb, int 
*flags, char *data)
clear_sbi_flag(sbi, SBI_NEED_SB_WRITE);
}
 
-   default_options(sbi);
-
/* parse mount options */
err = parse_options(sb, data);
if (err)
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v3] f2fs: surround fault_injection related option parsing using CONFIG_F2FS_FAULT_INJECTION

2018-09-11 Thread Chengguang Xu
It's a little bit strange when fault_injection related
options fail with -EINVAL which were already disabled
from config, so surround all fault_injection related option
parsing code using CONFIG_F2FS_FAULT_INJECTION. Meanwhile,
slightly change warning message to keep consistency with
option POSIX_ACL and FS_XATTR.

Signed-off-by: Chengguang Xu 
Reviewed-by: Chao Yu 
---
v1->v2:
- modify warning message
v2->v3:
- fix typo in title

 fs/f2fs/super.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 896b885f504e..ea6952c62e9f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -602,28 +602,31 @@ static int parse_options(struct super_block *sb, char 
*options)
}
F2FS_OPTION(sbi).write_io_size_bits = arg;
break;
+#ifdef CONFIG_F2FS_FAULT_INJECTION
case Opt_fault_injection:
if (args->from && match_int(args, ))
return -EINVAL;
-#ifdef CONFIG_F2FS_FAULT_INJECTION
f2fs_build_fault_attr(sbi, arg, F2FS_ALL_FAULT_TYPE);
set_opt(sbi, FAULT_INJECTION);
-#else
-   f2fs_msg(sb, KERN_INFO,
-   "FAULT_INJECTION was not selected");
-#endif
break;
+
case Opt_fault_type:
if (args->from && match_int(args, ))
return -EINVAL;
-#ifdef CONFIG_F2FS_FAULT_INJECTION
f2fs_build_fault_attr(sbi, 0, arg);
set_opt(sbi, FAULT_INJECTION);
+   break;
 #else
+   case Opt_fault_injection:
f2fs_msg(sb, KERN_INFO,
-   "FAULT_INJECTION was not selected");
-#endif
+   "fault_injection options not supported");
break;
+
+   case Opt_fault_type:
+   f2fs_msg(sb, KERN_INFO,
+   "fault_type options not supported");
+   break;
+#endif
case Opt_lazytime:
sb->s_flags |= SB_LAZYTIME;
break;
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2] f2fs: surround fault_injection ralted option parsing using CONFIG_F2FS_FAULT_INJECTION

2018-09-10 Thread Chengguang Xu
It's a little bit strange when fault_injection related
options fail with -EINVAL which were already disabled
from config, so surround all fault_injection related option
parsing code using CONFIG_F2FS_FAULT_INJECTION. Meanwhile,
slightly change warning message to keep consistency with
option POSIX_ACL and FS_XATTR.

Signed-off-by: Chengguang Xu 
---
v1->v2:
- modify warning message.

 fs/f2fs/super.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 896b885f504e..ea6952c62e9f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -602,28 +602,31 @@ static int parse_options(struct super_block *sb, char 
*options)
}
F2FS_OPTION(sbi).write_io_size_bits = arg;
break;
+#ifdef CONFIG_F2FS_FAULT_INJECTION
case Opt_fault_injection:
if (args->from && match_int(args, ))
return -EINVAL;
-#ifdef CONFIG_F2FS_FAULT_INJECTION
f2fs_build_fault_attr(sbi, arg, F2FS_ALL_FAULT_TYPE);
set_opt(sbi, FAULT_INJECTION);
-#else
-   f2fs_msg(sb, KERN_INFO,
-   "FAULT_INJECTION was not selected");
-#endif
break;
+
case Opt_fault_type:
if (args->from && match_int(args, ))
return -EINVAL;
-#ifdef CONFIG_F2FS_FAULT_INJECTION
f2fs_build_fault_attr(sbi, 0, arg);
set_opt(sbi, FAULT_INJECTION);
+   break;
 #else
+   case Opt_fault_injection:
f2fs_msg(sb, KERN_INFO,
-   "FAULT_INJECTION was not selected");
-#endif
+   "fault_injection options not supported");
break;
+
+   case Opt_fault_type:
+   f2fs_msg(sb, KERN_INFO,
+   "fault_type options not supported");
+   break;
+#endif
case Opt_lazytime:
sb->s_flags |= SB_LAZYTIME;
break;
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: surround fault_injection ralted option parsing using CONFIG_F2FS_FAULT_INJECTION

2018-09-10 Thread Chengguang Xu
It's a little bit strange when fault_injection related
options fail with -EINVAL which were already disabled
from config, so surround all fault_injection related option
parsing code using CONFIG_F2FS_FAULT_INJECTION. Meanwhile,
slightly change warning message to keep consistency with
option POSIX_ACL and FS_XATTR.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/super.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 896b885f504e..cc49cc10d9f5 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -602,28 +602,31 @@ static int parse_options(struct super_block *sb, char 
*options)
}
F2FS_OPTION(sbi).write_io_size_bits = arg;
break;
+#ifdef CONFIG_F2FS_FAULT_INJECTION
case Opt_fault_injection:
if (args->from && match_int(args, ))
return -EINVAL;
-#ifdef CONFIG_F2FS_FAULT_INJECTION
f2fs_build_fault_attr(sbi, arg, F2FS_ALL_FAULT_TYPE);
set_opt(sbi, FAULT_INJECTION);
-#else
-   f2fs_msg(sb, KERN_INFO,
-   "FAULT_INJECTION was not selected");
-#endif
break;
+
case Opt_fault_type:
if (args->from && match_int(args, ))
return -EINVAL;
-#ifdef CONFIG_F2FS_FAULT_INJECTION
f2fs_build_fault_attr(sbi, 0, arg);
set_opt(sbi, FAULT_INJECTION);
+   break;
 #else
+   case Opt_fault_injection:
f2fs_msg(sb, KERN_INFO,
-   "FAULT_INJECTION was not selected");
-#endif
+   "FAULT_INJECTION not supported");
break;
+
+   case Opt_fault_type:
+   f2fs_msg(sb, KERN_INFO,
+   "FAULT_INJECTION not supported");
+   break;
+#endif
case Opt_lazytime:
sb->s_flags |= SB_LAZYTIME;
break;
-- 
2.17.1



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 4/5] jfs: cache NULL when both default_acl and acl are NULL

2018-08-31 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
v1->v2:
- Coding style change.

 fs/jfs/acl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 2e71b6e7e646..8c06a6ea862d 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -146,12 +146,16 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct 
inode *dir)
if (default_acl) {
rc = __jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, default_acl);
posix_acl_release(default_acl);
+   } else {
+   inode->i_default_acl = NULL;
}
 
if (acl) {
if (!rc)
rc = __jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
posix_acl_release(acl);
+   } else {
+   inode->i_acl = NULL;
}
 
JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0x) |
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 5/5] orangefs: cache NULL when both default_acl and acl are NULL

2018-08-31 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
v1->v2:
- Coding style change.

 fs/orangefs/acl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 10587413b20e..72d2ff17d27b 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -167,12 +167,16 @@ int orangefs_init_acl(struct inode *inode, struct inode 
*dir)
error = __orangefs_set_acl(inode, default_acl,
   ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
+   } else {
+   inode->i_default_acl = NULL;
}
 
if (acl) {
if (!error)
error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
+   } else {
+   inode->i_acl = NULL;
}
 
/* If mode of the inode was changed, then do a forcible ->setattr */
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 2/5] ext4: cache NULL when both default_acl and acl are NULL

2018-08-31 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
v1->v2:
- Coding style change.

 fs/ext4/acl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index fb50f9aa6ead..c1d570ee1d9f 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -284,12 +284,16 @@ ext4_init_acl(handle_t *handle, struct inode *inode, 
struct inode *dir)
error = __ext4_set_acl(handle, inode, ACL_TYPE_DEFAULT,
   default_acl, XATTR_CREATE);
posix_acl_release(default_acl);
+   } else {
+   inode->i_default_acl = NULL;
}
if (acl) {
if (!error)
error = __ext4_set_acl(handle, inode, ACL_TYPE_ACCESS,
   acl, XATTR_CREATE);
posix_acl_release(acl);
+   } else {
+   inode->i_acl = NULL;
}
return error;
 }
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 1/5] ext2: cache NULL when both default_acl and acl are NULL

2018-08-31 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
v1->v2:
- Coding style change.

 fs/ext2/acl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 224c04abb2e5..cf4c77f8dd08 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -256,11 +256,15 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
if (default_acl) {
error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
+   } else {
+   inode->i_default_acl = NULL;
}
if (acl) {
if (!error)
error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
+   } else {
+   inode->i_acl = NULL;
}
return error;
 }
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: add additional sanity check in f2fs_acl_from_disk()

2018-08-31 Thread Chengguang Xu


On 2018/8/31 at 下午3:02, Chao Yu wrote:

> On 2018/8/31 0:19, cgxu519 wrote:
> > 
> > On 08/30/2018 11:41 PM, Chao Yu wrote:
> >> Hi Chengguang,
> >>
> >> On 2018/8/30 21:33, Chengguang Xu wrote:
> >>> Add additinal sanity check for irregular case(e.g. corruption).
> >>> If size of extended attribution is smaller than size of acl header,
> >>> then return -EINVAL.
> >>>
> >>> Signed-off-by: Chengguang Xu 
> >>> ---
> >>>   fs/f2fs/acl.c | 3 +++
> >>>   1 file changed, 3 insertions(+)
> >>>
> >>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> >>> index 111824199a88..79e9ea773070 100644
> >>> --- a/fs/f2fs/acl.c
> >>> +++ b/fs/f2fs/acl.c
> >>> @@ -53,6 +53,9 @@ static struct posix_acl *f2fs_acl_from_disk(const char 
> >>> *value, size_t size)
> >>>   struct f2fs_acl_entry *entry = (struct f2fs_acl_entry *)(hdr + 
> >>> 1);
> >>>   const char *end = value + size;
> >>>   
> >>> + if (size < sizeof(f2fs_acl_header))
> >>> + return ERR_PTR(-EINVAL);
> >> I guess below codes have checked that already?
> >>
> >>count = f2fs_acl_count(size);
> >>if (count < 0)
> >>return ERR_PTR(-EINVAL);
> > 
> > Hi Chao,
> > 
> > Thanks for prompt reply.
> > 
> > I still think in a rare case, it can pass the check in f2fs_acl_count() 
> > and cause unexpected behavior.
> > 
> > For example, like below code path in f2fs_acl_count().
> 
> if size < sizeof(f2fs_acl_header)
> 
> size -= sizeof(struct f2fs_acl_header);
> 
> size should be smaller than zero, right?
> 
> > 
> > -> if (s < 0) {
> >          if (size % sizeof(struct f2fs_acl_entry_short))
> >                   return -1;
> > ->    return size / sizeof(struct f2fs_acl_entry_short);
> 
> So the return value should be smaller than zero?

size is unsigned so the return value will not be negative here.

Thanks,
Chengguang

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: add additional sanity check in f2fs_acl_from_disk()

2018-08-30 Thread Chengguang Xu
Add additinal sanity check for irregular case(e.g. corruption).
If size of extended attribution is smaller than size of acl header,
then return -EINVAL.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/acl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 111824199a88..79e9ea773070 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -53,6 +53,9 @@ static struct posix_acl *f2fs_acl_from_disk(const char 
*value, size_t size)
struct f2fs_acl_entry *entry = (struct f2fs_acl_entry *)(hdr + 1);
const char *end = value + size;
 
+   if (size < sizeof(f2fs_acl_header))
+   return ERR_PTR(-EINVAL);
+
if (hdr->a_version != cpu_to_le32(F2FS_ACL_VERSION))
return ERR_PTR(-EINVAL);
 
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 5/5] orangefs: cache NULL when both default_acl and acl are NULL

2018-08-14 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
 fs/orangefs/acl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 10587413b20e..e3b043a263bc 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -175,6 +175,9 @@ int orangefs_init_acl(struct inode *inode, struct inode 
*dir)
posix_acl_release(acl);
}
 
+   if (!default_acl && !acl)
+   cache_no_acl(inode);
+
/* If mode of the inode was changed, then do a forcible ->setattr */
if (mode != inode->i_mode) {
memset(, 0, sizeof iattr);
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 1/5] ext2: cache NULL when both default_acl and acl are NULL

2018-08-14 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
 fs/ext2/acl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 224c04abb2e5..74411e8ea507 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -262,5 +262,8 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
}
+   if (!default_acl && !acl)
+   cache_no_acl(inode);
+
return error;
 }
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 4/5] jfs: cache NULL when both default_acl and acl are NULL

2018-08-14 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
 fs/jfs/acl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 2e71b6e7e646..15b9a9b74d72 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -154,6 +154,9 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct 
inode *dir)
posix_acl_release(acl);
}
 
+   if (!default_acl && !acl)
+   cache_no_acl(inode);
+
JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0x) |
   inode->i_mode;
 
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 2/5] ext4: cache NULL when both default_acl and acl are NULL

2018-08-14 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
 fs/ext4/acl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index fb50f9aa6ead..69a01d28356d 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -291,5 +291,8 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct 
inode *dir)
   acl, XATTR_CREATE);
posix_acl_release(acl);
}
+   if (!default_acl && !acl)
+   cache_no_acl(inode);
+
return error;
 }
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 3/5] f2fs: cache NULL when both default_acl and acl are NULL

2018-08-14 Thread Chengguang Xu
default_acl and acl of newly created inode will be initiated
as ACL_NOT_CACHED in vfs function inode_init_always() and later
will be updated by calling xxx_init_acl() in specific filesystems.
Howerver, when default_acl and acl are NULL then they keep the value
of ACL_NOT_CACHED, this patch tries to cache NULL for acl/default_acl
in this case.

Signed-off-by: Chengguang Xu 
---
 fs/f2fs/acl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 111824199a88..97ed555316be 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -401,6 +401,8 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir, 
struct page *ipage,
   ipage);
posix_acl_release(acl);
}
+   if (!default_acl && !acl)
+   cache_no_acl(inode);
 
return error;
 }
-- 
2.17.1


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel