All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
@ 2017-10-23 22:14 ` Jaegeuk Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Jaegeuk Kim @ 2017-10-23 22:14 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch adds to call quota_intialize in f2fs_set_acl.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/acl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 436b3a1464d9..f6471f9d707e 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
 	int error;
 	umode_t mode = inode->i_mode;
 
+	error = dquot_initialize(inode);
+	if (error)
+		return error;
+
 	switch (type) {
 	case ACL_TYPE_ACCESS:
 		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
@ 2017-10-23 22:14 ` Jaegeuk Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Jaegeuk Kim @ 2017-10-23 22:14 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch adds to call quota_intialize in f2fs_set_acl.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/acl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 436b3a1464d9..f6471f9d707e 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
 	int error;
 	umode_t mode = inode->i_mode;
 
+	error = dquot_initialize(inode);
+	if (error)
+		return error;
+
 	switch (type) {
 	case ACL_TYPE_ACCESS:
 		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
-- 
2.14.0.rc1.383.gd1ce394fe2-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/2] f2fs: stop all the operations by cp_error flag
  2017-10-23 22:14 ` Jaegeuk Kim
  (?)
@ 2017-10-23 22:14 ` Jaegeuk Kim
  2017-10-24  9:51     ` Chao Yu
  -1 siblings, 1 reply; 18+ messages in thread
From: Jaegeuk Kim @ 2017-10-23 22:14 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch replaces to use cp_error flag instead of RDONLY for quota off.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/acl.c        |  3 +++
 fs/f2fs/checkpoint.c |  1 -
 fs/f2fs/file.c       | 23 +++++++++++++++++++++++
 fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
 fs/f2fs/super.c      |  3 +++
 5 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index f6471f9d707e..a9bf5151e7c2 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
 
 int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
+		return -EIO;
+
 	return __f2fs_set_acl(inode, type, acl, NULL);
 }
 
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 201608281681..6b52d4b66c7b 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
 {
 	set_ckpt_flags(sbi, CP_ERROR_FLAG);
-	sbi->sb->s_flags |= MS_RDONLY;
 	if (!end_io)
 		f2fs_flush_merged_writes(sbi);
 }
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 56232a72d2a3..0e09b9f02dc5 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 	struct dnode_of_data dn;
 	int err;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	sb_start_pagefault(inode->i_sb);
 
 	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
@@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
 
 int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 {
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
+		return -EIO;
 	return f2fs_do_sync_file(file, start, end, datasync, false);
 }
 
@@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
 	struct inode *inode = file_inode(file);
 	int err;
 
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
+		return -EIO;
+
 	/* we don't need to use inline_data strictly */
 	err = f2fs_convert_inline_inode(inode);
 	if (err)
@@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
 {
 	int err;
 
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
+		return -EIO;
+
 	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
 				S_ISLNK(inode->i_mode)))
 		return 0;
@@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
 	int err;
 	bool size_changed = false;
 
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
+		return -EIO;
+
 	err = setattr_prepare(dentry, attr);
 	if (err)
 		return err;
@@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
 	struct inode *inode = file_inode(file);
 	long ret = 0;
 
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
+		return -EIO;
+
 	/* f2fs only support ->fallocate for regular file */
 	if (!S_ISREG(inode->i_mode))
 		return -EINVAL;
@@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
 
 long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
+		return -EIO;
+
 	switch (cmd) {
 	case F2FS_IOC_GETFLAGS:
 		return f2fs_ioc_getflags(filp, arg);
@@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	struct blk_plug plug;
 	ssize_t ret;
 
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
+		return -EIO;
+
 	inode_lock(inode);
 	ret = generic_write_checks(iocb, from);
 	if (ret > 0) {
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index e6f86d5d97b9..944f7a6940b6 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
 	nid_t ino = 0;
 	int err;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	err = dquot_initialize(dir);
 	if (err)
 		return err;
@@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
 	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
 	int err;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	if (f2fs_encrypted_inode(dir) &&
 			!fscrypt_has_permitted_context(dir, inode))
 		return -EPERM;
@@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
 
 	trace_f2fs_unlink_enter(dir, dentry);
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	err = dquot_initialize(dir);
 	if (err)
 		return err;
@@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
 	struct fscrypt_symlink_data *sd = NULL;
 	int err;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	if (f2fs_encrypted_inode(dir)) {
 		err = fscrypt_get_encryption_info(dir);
 		if (err)
@@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 	struct inode *inode;
 	int err;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	err = dquot_initialize(dir);
 	if (err)
 		return err;
@@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
 	struct inode *inode;
 	int err = 0;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	err = dquot_initialize(dir);
 	if (err)
 		return err;
@@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
 
 static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
+		return -EIO;
+
 	if (f2fs_encrypted_inode(dir)) {
 		int err = fscrypt_get_encryption_info(dir);
 		if (err)
@@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 
 static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
 {
+	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
+		return -EIO;
+
 	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
 }
 
@@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
 	int err = -ENOENT;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	if ((f2fs_encrypted_inode(old_dir) &&
 			!fscrypt_has_encryption_key(old_dir)) ||
 			(f2fs_encrypted_inode(new_dir) &&
@@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	int old_nlink = 0, new_nlink = 0;
 	int err = -ENOENT;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return -EIO;
+
 	if ((f2fs_encrypted_inode(old_dir) &&
 			!fscrypt_has_encryption_key(old_dir)) ||
 			(f2fs_encrypted_inode(new_dir) &&
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7659b348582a..213d2c1e5759 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
 	int err = 0;
 
+	if (unlikely(f2fs_cp_error(sbi)))
+		return 0;
+
 	trace_f2fs_sync_fs(sb, sync);
 
 	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
  2017-10-23 22:14 ` Jaegeuk Kim
@ 2017-10-24  9:46   ` Chao Yu
  -1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-24  9:46 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/10/24 6:14, Jaegeuk Kim wrote:
> This patch adds to call quota_intialize in f2fs_set_acl.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/acl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index 436b3a1464d9..f6471f9d707e 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>  	int error;
>  	umode_t mode = inode->i_mode;
>  
> +	error = dquot_initialize(inode);
> +	if (error)
> +		return error;

Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
unlink and rename like ext4?

Thanks,

> +
>  	switch (type) {
>  	case ACL_TYPE_ACCESS:
>  		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
@ 2017-10-24  9:46   ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-24  9:46 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/10/24 6:14, Jaegeuk Kim wrote:
> This patch adds to call quota_intialize in f2fs_set_acl.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/acl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index 436b3a1464d9..f6471f9d707e 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>  	int error;
>  	umode_t mode = inode->i_mode;
>  
> +	error = dquot_initialize(inode);
> +	if (error)
> +		return error;

Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
unlink and rename like ext4?

Thanks,

> +
>  	switch (type) {
>  	case ACL_TYPE_ACCESS:
>  		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: stop all the operations by cp_error flag
  2017-10-23 22:14 ` [PATCH 2/2] f2fs: stop all the operations by cp_error flag Jaegeuk Kim
@ 2017-10-24  9:51     ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-24  9:51 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/10/24 6:14, Jaegeuk Kim wrote:
> This patch replaces to use cp_error flag instead of RDONLY for quota off.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> ---
>  fs/f2fs/acl.c        |  3 +++
>  fs/f2fs/checkpoint.c |  1 -
>  fs/f2fs/file.c       | 23 +++++++++++++++++++++++
>  fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
>  fs/f2fs/super.c      |  3 +++
>  5 files changed, 59 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index f6471f9d707e..a9bf5151e7c2 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>  
>  int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	return __f2fs_set_acl(inode, type, acl, NULL);
>  }
>  
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 201608281681..6b52d4b66c7b 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
>  void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
>  {
>  	set_ckpt_flags(sbi, CP_ERROR_FLAG);
> -	sbi->sb->s_flags |= MS_RDONLY;
>  	if (!end_io)
>  		f2fs_flush_merged_writes(sbi);
>  }
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 56232a72d2a3..0e09b9f02dc5 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>  	struct dnode_of_data dn;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	sb_start_pagefault(inode->i_sb);
>  
>  	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
> @@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
>  
>  int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
> +		return -EIO;
>  	return f2fs_do_sync_file(file, start, end, datasync, false);
>  }
>  
> @@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
>  	struct inode *inode = file_inode(file);
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	/* we don't need to use inline_data strictly */
>  	err = f2fs_convert_inline_inode(inode);
>  	if (err)
> @@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
>  {
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
>  				S_ISLNK(inode->i_mode)))
>  		return 0;
> @@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>  	int err;
>  	bool size_changed = false;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	err = setattr_prepare(dentry, attr);
>  	if (err)
>  		return err;
> @@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
>  	struct inode *inode = file_inode(file);
>  	long ret = 0;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	/* f2fs only support ->fallocate for regular file */
>  	if (!S_ISREG(inode->i_mode))
>  		return -EINVAL;
> @@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
>  
>  long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
> +		return -EIO;
> +
>  	switch (cmd) {
>  	case F2FS_IOC_GETFLAGS:
>  		return f2fs_ioc_getflags(filp, arg);
> @@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  	struct blk_plug plug;
>  	ssize_t ret;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	inode_lock(inode);
>  	ret = generic_write_checks(iocb, from);
>  	if (ret > 0) {
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index e6f86d5d97b9..944f7a6940b6 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
>  	nid_t ino = 0;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
>  	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if (f2fs_encrypted_inode(dir) &&
>  			!fscrypt_has_permitted_context(dir, inode))
>  		return -EPERM;
> @@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
>  
>  	trace_f2fs_unlink_enter(dir, dentry);
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
>  	struct fscrypt_symlink_data *sd = NULL;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if (f2fs_encrypted_inode(dir)) {
>  		err = fscrypt_get_encryption_info(dir);
>  		if (err)
> @@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  	struct inode *inode;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
>  	struct inode *inode;
>  	int err = 0;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
>  
>  static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> +		return -EIO;
> +
>  	if (f2fs_encrypted_inode(dir)) {
>  		int err = fscrypt_get_encryption_info(dir);
>  		if (err)
> @@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>  
>  static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> +		return -EIO;
> +
>  	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
>  }
>  
> @@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
>  	int err = -ENOENT;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if ((f2fs_encrypted_inode(old_dir) &&
>  			!fscrypt_has_encryption_key(old_dir)) ||
>  			(f2fs_encrypted_inode(new_dir) &&
> @@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	int old_nlink = 0, new_nlink = 0;
>  	int err = -ENOENT;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if ((f2fs_encrypted_inode(old_dir) &&
>  			!fscrypt_has_encryption_key(old_dir)) ||
>  			(f2fs_encrypted_inode(new_dir) &&
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 7659b348582a..213d2c1e5759 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
>  	int err = 0;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return 0;
> +
>  	trace_f2fs_sync_fs(sb, sync);
>  
>  	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: stop all the operations by cp_error flag
@ 2017-10-24  9:51     ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-24  9:51 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/10/24 6:14, Jaegeuk Kim wrote:
> This patch replaces to use cp_error flag instead of RDONLY for quota off.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> ---
>  fs/f2fs/acl.c        |  3 +++
>  fs/f2fs/checkpoint.c |  1 -
>  fs/f2fs/file.c       | 23 +++++++++++++++++++++++
>  fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
>  fs/f2fs/super.c      |  3 +++
>  5 files changed, 59 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index f6471f9d707e..a9bf5151e7c2 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>  
>  int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	return __f2fs_set_acl(inode, type, acl, NULL);
>  }
>  
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 201608281681..6b52d4b66c7b 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
>  void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
>  {
>  	set_ckpt_flags(sbi, CP_ERROR_FLAG);
> -	sbi->sb->s_flags |= MS_RDONLY;
>  	if (!end_io)
>  		f2fs_flush_merged_writes(sbi);
>  }
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 56232a72d2a3..0e09b9f02dc5 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>  	struct dnode_of_data dn;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	sb_start_pagefault(inode->i_sb);
>  
>  	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
> @@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
>  
>  int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
> +		return -EIO;
>  	return f2fs_do_sync_file(file, start, end, datasync, false);
>  }
>  
> @@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
>  	struct inode *inode = file_inode(file);
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	/* we don't need to use inline_data strictly */
>  	err = f2fs_convert_inline_inode(inode);
>  	if (err)
> @@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
>  {
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
>  				S_ISLNK(inode->i_mode)))
>  		return 0;
> @@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>  	int err;
>  	bool size_changed = false;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	err = setattr_prepare(dentry, attr);
>  	if (err)
>  		return err;
> @@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
>  	struct inode *inode = file_inode(file);
>  	long ret = 0;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	/* f2fs only support ->fallocate for regular file */
>  	if (!S_ISREG(inode->i_mode))
>  		return -EINVAL;
> @@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
>  
>  long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
> +		return -EIO;
> +
>  	switch (cmd) {
>  	case F2FS_IOC_GETFLAGS:
>  		return f2fs_ioc_getflags(filp, arg);
> @@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  	struct blk_plug plug;
>  	ssize_t ret;
>  
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> +		return -EIO;
> +
>  	inode_lock(inode);
>  	ret = generic_write_checks(iocb, from);
>  	if (ret > 0) {
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index e6f86d5d97b9..944f7a6940b6 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
>  	nid_t ino = 0;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
>  	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if (f2fs_encrypted_inode(dir) &&
>  			!fscrypt_has_permitted_context(dir, inode))
>  		return -EPERM;
> @@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
>  
>  	trace_f2fs_unlink_enter(dir, dentry);
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
>  	struct fscrypt_symlink_data *sd = NULL;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if (f2fs_encrypted_inode(dir)) {
>  		err = fscrypt_get_encryption_info(dir);
>  		if (err)
> @@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>  	struct inode *inode;
>  	int err;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
>  	struct inode *inode;
>  	int err = 0;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	err = dquot_initialize(dir);
>  	if (err)
>  		return err;
> @@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
>  
>  static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> +		return -EIO;
> +
>  	if (f2fs_encrypted_inode(dir)) {
>  		int err = fscrypt_get_encryption_info(dir);
>  		if (err)
> @@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>  
>  static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
>  {
> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> +		return -EIO;
> +
>  	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
>  }
>  
> @@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
>  	int err = -ENOENT;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if ((f2fs_encrypted_inode(old_dir) &&
>  			!fscrypt_has_encryption_key(old_dir)) ||
>  			(f2fs_encrypted_inode(new_dir) &&
> @@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	int old_nlink = 0, new_nlink = 0;
>  	int err = -ENOENT;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return -EIO;
> +
>  	if ((f2fs_encrypted_inode(old_dir) &&
>  			!fscrypt_has_encryption_key(old_dir)) ||
>  			(f2fs_encrypted_inode(new_dir) &&
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 7659b348582a..213d2c1e5759 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
>  	int err = 0;
>  
> +	if (unlikely(f2fs_cp_error(sbi)))
> +		return 0;
> +
>  	trace_f2fs_sync_fs(sb, sync);
>  
>  	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v2] f2fs: add missing quota_initialize in f2fs_set_acl
  2017-10-23 22:14 ` Jaegeuk Kim
                   ` (2 preceding siblings ...)
  (?)
@ 2017-10-25  5:43 ` Jaegeuk Kim
  -1 siblings, 0 replies; 18+ messages in thread
From: Jaegeuk Kim @ 2017-10-25  5:43 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel

This patch adds to call quota_intialize in f2fs_set_acl.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/xattr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 147b481c6902..8801db019892 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -686,6 +686,10 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	int err;
 
+	err = dquot_initialize(inode);
+	if (err)
+		return err;
+
 	/* this case is only from init_inode_metadata */
 	if (ipage)
 		return __f2fs_setxattr(inode, index, name, value,
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
  2017-10-24  9:46   ` Chao Yu
  (?)
@ 2017-10-25  5:44   ` Jaegeuk Kim
  2017-10-25  5:57       ` Chao Yu
  -1 siblings, 1 reply; 18+ messages in thread
From: Jaegeuk Kim @ 2017-10-25  5:44 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On 10/24, Chao Yu wrote:
> On 2017/10/24 6:14, Jaegeuk Kim wrote:
> > This patch adds to call quota_intialize in f2fs_set_acl.
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  fs/f2fs/acl.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> > index 436b3a1464d9..f6471f9d707e 100644
> > --- a/fs/f2fs/acl.c
> > +++ b/fs/f2fs/acl.c
> > @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
> >  	int error;
> >  	umode_t mode = inode->i_mode;
> >  
> > +	error = dquot_initialize(inode);
> > +	if (error)
> > +		return error;
> 
> Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
> unlink and rename like ext4?

I've checked that f2fs_unlink and f2fs_rename are calling dquot_initialize().

Thanks,

> 
> Thanks,
> 
> > +
> >  	switch (type) {
> >  	case ACL_TYPE_ACCESS:
> >  		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
> > 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
  2017-10-25  5:44   ` Jaegeuk Kim
@ 2017-10-25  5:57       ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-25  5:57 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/10/25 13:44, Jaegeuk Kim wrote:
> On 10/24, Chao Yu wrote:
>> On 2017/10/24 6:14, Jaegeuk Kim wrote:
>>> This patch adds to call quota_intialize in f2fs_set_acl.
>>>
>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>> ---
>>>  fs/f2fs/acl.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>>> index 436b3a1464d9..f6471f9d707e 100644
>>> --- a/fs/f2fs/acl.c
>>> +++ b/fs/f2fs/acl.c
>>> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>>>  	int error;
>>>  	umode_t mode = inode->i_mode;
>>>  
>>> +	error = dquot_initialize(inode);
>>> +	if (error)
>>> +		return error;
>>
>> Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
>> unlink and rename like ext4?
> 
> I've checked that f2fs_unlink and f2fs_rename are calling dquot_initialize().

ext4_unlink:

	retval = dquot_initialize(dir);
	if (retval)
		return retval;
	retval = dquot_initialize(d_inode(dentry));
	if (retval)
		return retval;

f2fs_unlink:

	err = dquot_initialize(dir);
	if (err)
		return err;

ext4_rename

	retval = dquot_initialize(old.dir);
	if (retval)
		return retval;
	retval = dquot_initialize(new.dir);
	if (retval)
		return retval;

	/* Initialize quotas before so that eventual writes go
	 * in separate transaction */
	if (new.inode) {
		retval = dquot_initialize(new.inode);
		if (retval)
			return retval;
	}

f2fs_rename

	err = dquot_initialize(old_dir);
	if (err)
		goto out;

	err = dquot_initialize(new_dir);
	if (err)
		goto out;

ext4 call one more dquot_initialize than f2fs, I didn't look into this in
detail, but it's better to check that. :)

Thanks,
> 
> Thanks,
> 
>>
>> Thanks,
>>
>>> +
>>>  	switch (type) {
>>>  	case ACL_TYPE_ACCESS:
>>>  		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
>>>
> 
> .
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
@ 2017-10-25  5:57       ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-25  5:57 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On 2017/10/25 13:44, Jaegeuk Kim wrote:
> On 10/24, Chao Yu wrote:
>> On 2017/10/24 6:14, Jaegeuk Kim wrote:
>>> This patch adds to call quota_intialize in f2fs_set_acl.
>>>
>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>> ---
>>>  fs/f2fs/acl.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>>> index 436b3a1464d9..f6471f9d707e 100644
>>> --- a/fs/f2fs/acl.c
>>> +++ b/fs/f2fs/acl.c
>>> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>>>  	int error;
>>>  	umode_t mode = inode->i_mode;
>>>  
>>> +	error = dquot_initialize(inode);
>>> +	if (error)
>>> +		return error;
>>
>> Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
>> unlink and rename like ext4?
> 
> I've checked that f2fs_unlink and f2fs_rename are calling dquot_initialize().

ext4_unlink:

	retval = dquot_initialize(dir);
	if (retval)
		return retval;
	retval = dquot_initialize(d_inode(dentry));
	if (retval)
		return retval;

f2fs_unlink:

	err = dquot_initialize(dir);
	if (err)
		return err;

ext4_rename

	retval = dquot_initialize(old.dir);
	if (retval)
		return retval;
	retval = dquot_initialize(new.dir);
	if (retval)
		return retval;

	/* Initialize quotas before so that eventual writes go
	 * in separate transaction */
	if (new.inode) {
		retval = dquot_initialize(new.inode);
		if (retval)
			return retval;
	}

f2fs_rename

	err = dquot_initialize(old_dir);
	if (err)
		goto out;

	err = dquot_initialize(new_dir);
	if (err)
		goto out;

ext4 call one more dquot_initialize than f2fs, I didn't look into this in
detail, but it's better to check that. :)

Thanks,
> 
> Thanks,
> 
>>
>> Thanks,
>>
>>> +
>>>  	switch (type) {
>>>  	case ACL_TYPE_ACCESS:
>>>  		name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
>>>
> 
> .
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
  2017-10-25  5:57       ` Chao Yu
  (?)
@ 2017-10-25  6:30       ` Jaegeuk Kim
  2017-10-25 15:47           ` Chao Yu
  -1 siblings, 1 reply; 18+ messages in thread
From: Jaegeuk Kim @ 2017-10-25  6:30 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On 10/25, Chao Yu wrote:
> On 2017/10/25 13:44, Jaegeuk Kim wrote:
> > On 10/24, Chao Yu wrote:
> >> On 2017/10/24 6:14, Jaegeuk Kim wrote:
> >>> This patch adds to call quota_intialize in f2fs_set_acl.
> >>>
> >>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> >>> ---
> >>>  fs/f2fs/acl.c | 4 ++++
> >>>  1 file changed, 4 insertions(+)
> >>>
> >>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> >>> index 436b3a1464d9..f6471f9d707e 100644
> >>> --- a/fs/f2fs/acl.c
> >>> +++ b/fs/f2fs/acl.c
> >>> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
> >>>  	int error;
> >>>  	umode_t mode = inode->i_mode;
> >>>  
> >>> +	error = dquot_initialize(inode);
> >>> +	if (error)
> >>> +		return error;
> >>
> >> Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
> >> unlink and rename like ext4?
> > 
> > I've checked that f2fs_unlink and f2fs_rename are calling dquot_initialize().
> 
> ext4_unlink:
> 
> 	retval = dquot_initialize(dir);
> 	if (retval)
> 		return retval;
> 	retval = dquot_initialize(d_inode(dentry));
> 	if (retval)
> 		return retval;
> 
> f2fs_unlink:
> 
> 	err = dquot_initialize(dir);
> 	if (err)
> 		return err;
> 
> ext4_rename
> 
> 	retval = dquot_initialize(old.dir);
> 	if (retval)
> 		return retval;
> 	retval = dquot_initialize(new.dir);
> 	if (retval)
> 		return retval;
> 
> 	/* Initialize quotas before so that eventual writes go
> 	 * in separate transaction */
> 	if (new.inode) {
> 		retval = dquot_initialize(new.inode);
> 		if (retval)
> 			return retval;
> 	}
> 
> f2fs_rename
> 
> 	err = dquot_initialize(old_dir);
> 	if (err)
> 		goto out;
> 
> 	err = dquot_initialize(new_dir);
> 	if (err)
> 		goto out;
> 
> ext4 call one more dquot_initialize than f2fs, I didn't look into this in
> detail, but it's better to check that. :)

Ah, okay. :)

This patch adds to call quota_intialize in f2fs_set_acl, f2fs_unlink,
and f2fs_rename.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/namei.c | 9 +++++++++
 fs/f2fs/xattr.c | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 944f7a6940b6..35d982a475b1 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -436,6 +436,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
 		return -EIO;
 
 	err = dquot_initialize(dir);
+	if (err)
+		return err;
+	err = dquot_initialize(inode);
 	if (err)
 		return err;
 
@@ -815,6 +818,12 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (err)
 		goto out;
 
+	if (new_inode) {
+		err = dquot_initialize(new_inode);
+		if (err)
+			goto out;
+	}
+
 	old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);
 	if (!old_entry) {
 		if (IS_ERR(old_page))
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 147b481c6902..8801db019892 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -686,6 +686,10 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
 	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	int err;
 
+	err = dquot_initialize(inode);
+	if (err)
+		return err;
+
 	/* this case is only from init_inode_metadata */
 	if (ipage)
 		return __f2fs_setxattr(inode, index, name, value,
-- 
2.14.0.rc1.383.gd1ce394fe2-goog

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [f2fs-dev] [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
  2017-10-25  6:30       ` Jaegeuk Kim
@ 2017-10-25 15:47           ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-25 15:47 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

On 2017/10/25 14:30, Jaegeuk Kim wrote:
> On 10/25, Chao Yu wrote:
>> On 2017/10/25 13:44, Jaegeuk Kim wrote:
>>> On 10/24, Chao Yu wrote:
>>>> On 2017/10/24 6:14, Jaegeuk Kim wrote:
>>>>> This patch adds to call quota_intialize in f2fs_set_acl.
>>>>>
>>>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>>>> ---
>>>>>  fs/f2fs/acl.c | 4 ++++
>>>>>  1 file changed, 4 insertions(+)
>>>>>
>>>>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>>>>> index 436b3a1464d9..f6471f9d707e 100644
>>>>> --- a/fs/f2fs/acl.c
>>>>> +++ b/fs/f2fs/acl.c
>>>>> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>>>>>  	int error;
>>>>>  	umode_t mode = inode->i_mode;
>>>>>  
>>>>> +	error = dquot_initialize(inode);
>>>>> +	if (error)
>>>>> +		return error;
>>>>
>>>> Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
>>>> unlink and rename like ext4?
>>>
>>> I've checked that f2fs_unlink and f2fs_rename are calling dquot_initialize().
>>
>> ext4_unlink:
>>
>> 	retval = dquot_initialize(dir);
>> 	if (retval)
>> 		return retval;
>> 	retval = dquot_initialize(d_inode(dentry));
>> 	if (retval)
>> 		return retval;
>>
>> f2fs_unlink:
>>
>> 	err = dquot_initialize(dir);
>> 	if (err)
>> 		return err;
>>
>> ext4_rename
>>
>> 	retval = dquot_initialize(old.dir);
>> 	if (retval)
>> 		return retval;
>> 	retval = dquot_initialize(new.dir);
>> 	if (retval)
>> 		return retval;
>>
>> 	/* Initialize quotas before so that eventual writes go
>> 	 * in separate transaction */
>> 	if (new.inode) {
>> 		retval = dquot_initialize(new.inode);
>> 		if (retval)
>> 			return retval;
>> 	}
>>
>> f2fs_rename
>>
>> 	err = dquot_initialize(old_dir);
>> 	if (err)
>> 		goto out;
>>
>> 	err = dquot_initialize(new_dir);
>> 	if (err)
>> 		goto out;
>>
>> ext4 call one more dquot_initialize than f2fs, I didn't look into this in
>> detail, but it's better to check that. :)
> 
> Ah, okay. :)
> 
> This patch adds to call quota_intialize in f2fs_set_acl, f2fs_unlink,
> and f2fs_rename.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> ---
>  fs/f2fs/namei.c | 9 +++++++++
>  fs/f2fs/xattr.c | 4 ++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 944f7a6940b6..35d982a475b1 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -436,6 +436,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
>  		return -EIO;
>  
>  	err = dquot_initialize(dir);
> +	if (err)
> +		return err;
> +	err = dquot_initialize(inode);
>  	if (err)
>  		return err;
>  
> @@ -815,6 +818,12 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	if (err)
>  		goto out;
>  
> +	if (new_inode) {
> +		err = dquot_initialize(new_inode);
> +		if (err)
> +			goto out;
> +	}
> +
>  	old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);
>  	if (!old_entry) {
>  		if (IS_ERR(old_page))
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 147b481c6902..8801db019892 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -686,6 +686,10 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
>  	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>  	int err;
>  
> +	err = dquot_initialize(inode);
> +	if (err)
> +		return err;
> +
>  	/* this case is only from init_inode_metadata */
>  	if (ipage)
>  		return __f2fs_setxattr(inode, index, name, value,
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl
@ 2017-10-25 15:47           ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-10-25 15:47 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

On 2017/10/25 14:30, Jaegeuk Kim wrote:
> On 10/25, Chao Yu wrote:
>> On 2017/10/25 13:44, Jaegeuk Kim wrote:
>>> On 10/24, Chao Yu wrote:
>>>> On 2017/10/24 6:14, Jaegeuk Kim wrote:
>>>>> This patch adds to call quota_intialize in f2fs_set_acl.
>>>>>
>>>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>>>> ---
>>>>>  fs/f2fs/acl.c | 4 ++++
>>>>>  1 file changed, 4 insertions(+)
>>>>>
>>>>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>>>>> index 436b3a1464d9..f6471f9d707e 100644
>>>>> --- a/fs/f2fs/acl.c
>>>>> +++ b/fs/f2fs/acl.c
>>>>> @@ -209,6 +209,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>>>>>  	int error;
>>>>>  	umode_t mode = inode->i_mode;
>>>>>  
>>>>> +	error = dquot_initialize(inode);
>>>>> +	if (error)
>>>>> +		return error;
>>>>
>>>> Could you move this to f2fs_setxattr, and also add missing dquot_initialize in
>>>> unlink and rename like ext4?
>>>
>>> I've checked that f2fs_unlink and f2fs_rename are calling dquot_initialize().
>>
>> ext4_unlink:
>>
>> 	retval = dquot_initialize(dir);
>> 	if (retval)
>> 		return retval;
>> 	retval = dquot_initialize(d_inode(dentry));
>> 	if (retval)
>> 		return retval;
>>
>> f2fs_unlink:
>>
>> 	err = dquot_initialize(dir);
>> 	if (err)
>> 		return err;
>>
>> ext4_rename
>>
>> 	retval = dquot_initialize(old.dir);
>> 	if (retval)
>> 		return retval;
>> 	retval = dquot_initialize(new.dir);
>> 	if (retval)
>> 		return retval;
>>
>> 	/* Initialize quotas before so that eventual writes go
>> 	 * in separate transaction */
>> 	if (new.inode) {
>> 		retval = dquot_initialize(new.inode);
>> 		if (retval)
>> 			return retval;
>> 	}
>>
>> f2fs_rename
>>
>> 	err = dquot_initialize(old_dir);
>> 	if (err)
>> 		goto out;
>>
>> 	err = dquot_initialize(new_dir);
>> 	if (err)
>> 		goto out;
>>
>> ext4 call one more dquot_initialize than f2fs, I didn't look into this in
>> detail, but it's better to check that. :)
> 
> Ah, okay. :)
> 
> This patch adds to call quota_intialize in f2fs_set_acl, f2fs_unlink,
> and f2fs_rename.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> ---
>  fs/f2fs/namei.c | 9 +++++++++
>  fs/f2fs/xattr.c | 4 ++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 944f7a6940b6..35d982a475b1 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -436,6 +436,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
>  		return -EIO;
>  
>  	err = dquot_initialize(dir);
> +	if (err)
> +		return err;
> +	err = dquot_initialize(inode);
>  	if (err)
>  		return err;
>  
> @@ -815,6 +818,12 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	if (err)
>  		goto out;
>  
> +	if (new_inode) {
> +		err = dquot_initialize(new_inode);
> +		if (err)
> +			goto out;
> +	}
> +
>  	old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);
>  	if (!old_entry) {
>  		if (IS_ERR(old_page))
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 147b481c6902..8801db019892 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -686,6 +686,10 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
>  	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>  	int err;
>  
> +	err = dquot_initialize(inode);
> +	if (err)
> +		return err;
> +
>  	/* this case is only from init_inode_metadata */
>  	if (ipage)
>  		return __f2fs_setxattr(inode, index, name, value,
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: stop all the operations by cp_error flag
  2017-10-24  9:51     ` Chao Yu
@ 2017-11-05  3:39       ` Chao Yu
  -1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-11-05  3:39 UTC (permalink / raw)
  To: Chao Yu, Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

Hi Jaegeuk,

On 2017/10/24 17:51, Chao Yu wrote:
> On 2017/10/24 6:14, Jaegeuk Kim wrote:
>> This patch replaces to use cp_error flag instead of RDONLY for quota off.

We should convert error number with block_page_mkwrite_return in .page_mkwrite,
otherwise generic/019 will cause a deadlock issue with below kernel message
printed:

============================================
WARNING: possible recursive locking detected
4.14.0-rc1 #35 Tainted: G        W  O
--------------------------------------------
fio/5845 is trying to acquire lock:
 (&mm->mmap_sem){++++}, at: [<c104be02>] __do_page_fault+0x482/0x510

but task is already holding lock:
 (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&mm->mmap_sem);
  lock(&mm->mmap_sem);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

1 lock held by fio/5845:
 #0:  (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510

stack backtrace:
CPU: 3 PID: 5845 Comm: fio Tainted: G        W  O    4.14.0-rc1 #35
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
Call Trace:
 dump_stack+0x5f/0x92
 __lock_acquire+0x1019/0x12c0
 lock_acquire+0xae/0x220
 down_read+0x38/0x60
 __do_page_fault+0x482/0x510
 do_page_fault+0x26/0x290
 common_exception+0x64/0x6a


---
 fs/f2fs/file.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index e67f03546391..0ce1e82591d1 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -53,8 +53,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 	struct dnode_of_data dn;
 	int err;

-	if (unlikely(f2fs_cp_error(sbi)))
-		return -EIO;
+	if (unlikely(f2fs_cp_error(sbi))) {
+		err = -EIO;
+		goto out;
+	}

 	sb_start_pagefault(inode->i_sb);

@@ -66,7 +68,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 	err = f2fs_reserve_block(&dn, page->index);
 	if (err) {
 		f2fs_unlock_op(sbi);
-		goto out;
+		goto out_end;
 	}
 	f2fs_put_dnode(&dn);
 	f2fs_unlock_op(sbi);
@@ -114,9 +116,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)

 out_sem:
 	up_read(&F2FS_I(inode)->i_mmap_sem);
-out:
+out_end:
 	sb_end_pagefault(inode->i_sb);
 	f2fs_update_time(sbi, REQ_TIME);
+out:
 	return block_page_mkwrite_return(err);
 }

-- 


Thanks,

>>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
>> ---
>>  fs/f2fs/acl.c        |  3 +++
>>  fs/f2fs/checkpoint.c |  1 -
>>  fs/f2fs/file.c       | 23 +++++++++++++++++++++++
>>  fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
>>  fs/f2fs/super.c      |  3 +++
>>  5 files changed, 59 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>> index f6471f9d707e..a9bf5151e7c2 100644
>> --- a/fs/f2fs/acl.c
>> +++ b/fs/f2fs/acl.c
>> @@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>>  
>>  int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	return __f2fs_set_acl(inode, type, acl, NULL);
>>  }
>>  
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index 201608281681..6b52d4b66c7b 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
>>  void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
>>  {
>>  	set_ckpt_flags(sbi, CP_ERROR_FLAG);
>> -	sbi->sb->s_flags |= MS_RDONLY;
>>  	if (!end_io)
>>  		f2fs_flush_merged_writes(sbi);
>>  }
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 56232a72d2a3..0e09b9f02dc5 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>>  	struct dnode_of_data dn;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	sb_start_pagefault(inode->i_sb);
>>  
>>  	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
>> @@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
>>  
>>  int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
>> +		return -EIO;
>>  	return f2fs_do_sync_file(file, start, end, datasync, false);
>>  }
>>  
>> @@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
>>  	struct inode *inode = file_inode(file);
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	/* we don't need to use inline_data strictly */
>>  	err = f2fs_convert_inline_inode(inode);
>>  	if (err)
>> @@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
>>  {
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
>>  				S_ISLNK(inode->i_mode)))
>>  		return 0;
>> @@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>>  	int err;
>>  	bool size_changed = false;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	err = setattr_prepare(dentry, attr);
>>  	if (err)
>>  		return err;
>> @@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
>>  	struct inode *inode = file_inode(file);
>>  	long ret = 0;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	/* f2fs only support ->fallocate for regular file */
>>  	if (!S_ISREG(inode->i_mode))
>>  		return -EINVAL;
>> @@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
>>  
>>  long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
>> +		return -EIO;
>> +
>>  	switch (cmd) {
>>  	case F2FS_IOC_GETFLAGS:
>>  		return f2fs_ioc_getflags(filp, arg);
>> @@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
>>  	struct blk_plug plug;
>>  	ssize_t ret;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	inode_lock(inode);
>>  	ret = generic_write_checks(iocb, from);
>>  	if (ret > 0) {
>> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
>> index e6f86d5d97b9..944f7a6940b6 100644
>> --- a/fs/f2fs/namei.c
>> +++ b/fs/f2fs/namei.c
>> @@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
>>  	nid_t ino = 0;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
>>  	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if (f2fs_encrypted_inode(dir) &&
>>  			!fscrypt_has_permitted_context(dir, inode))
>>  		return -EPERM;
>> @@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
>>  
>>  	trace_f2fs_unlink_enter(dir, dentry);
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
>>  	struct fscrypt_symlink_data *sd = NULL;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if (f2fs_encrypted_inode(dir)) {
>>  		err = fscrypt_get_encryption_info(dir);
>>  		if (err)
>> @@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  	struct inode *inode;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
>>  	struct inode *inode;
>>  	int err = 0;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
>>  
>>  static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
>> +		return -EIO;
>> +
>>  	if (f2fs_encrypted_inode(dir)) {
>>  		int err = fscrypt_get_encryption_info(dir);
>>  		if (err)
>> @@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  
>>  static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
>> +		return -EIO;
>> +
>>  	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
>>  }
>>  
>> @@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
>>  	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
>>  	int err = -ENOENT;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if ((f2fs_encrypted_inode(old_dir) &&
>>  			!fscrypt_has_encryption_key(old_dir)) ||
>>  			(f2fs_encrypted_inode(new_dir) &&
>> @@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>>  	int old_nlink = 0, new_nlink = 0;
>>  	int err = -ENOENT;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if ((f2fs_encrypted_inode(old_dir) &&
>>  			!fscrypt_has_encryption_key(old_dir)) ||
>>  			(f2fs_encrypted_inode(new_dir) &&
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 7659b348582a..213d2c1e5759 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
>>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
>>  	int err = 0;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return 0;
>> +
>>  	trace_f2fs_sync_fs(sb, sync);
>>  
>>  	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
>>
> 
> 
> ------------------------------------------------------------------------------
> 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
> 

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/2] f2fs: stop all the operations by cp_error flag
@ 2017-11-05  3:39       ` Chao Yu
  0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2017-11-05  3:39 UTC (permalink / raw)
  To: Chao Yu, Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel

Hi Jaegeuk,

On 2017/10/24 17:51, Chao Yu wrote:
> On 2017/10/24 6:14, Jaegeuk Kim wrote:
>> This patch replaces to use cp_error flag instead of RDONLY for quota off.

We should convert error number with block_page_mkwrite_return in .page_mkwrite,
otherwise generic/019 will cause a deadlock issue with below kernel message
printed:

============================================
WARNING: possible recursive locking detected
4.14.0-rc1 #35 Tainted: G        W  O
--------------------------------------------
fio/5845 is trying to acquire lock:
 (&mm->mmap_sem){++++}, at: [<c104be02>] __do_page_fault+0x482/0x510

but task is already holding lock:
 (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&mm->mmap_sem);
  lock(&mm->mmap_sem);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

1 lock held by fio/5845:
 #0:  (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510

stack backtrace:
CPU: 3 PID: 5845 Comm: fio Tainted: G        W  O    4.14.0-rc1 #35
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
Call Trace:
 dump_stack+0x5f/0x92
 __lock_acquire+0x1019/0x12c0
 lock_acquire+0xae/0x220
 down_read+0x38/0x60
 __do_page_fault+0x482/0x510
 do_page_fault+0x26/0x290
 common_exception+0x64/0x6a


---
 fs/f2fs/file.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index e67f03546391..0ce1e82591d1 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -53,8 +53,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 	struct dnode_of_data dn;
 	int err;

-	if (unlikely(f2fs_cp_error(sbi)))
-		return -EIO;
+	if (unlikely(f2fs_cp_error(sbi))) {
+		err = -EIO;
+		goto out;
+	}

 	sb_start_pagefault(inode->i_sb);

@@ -66,7 +68,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 	err = f2fs_reserve_block(&dn, page->index);
 	if (err) {
 		f2fs_unlock_op(sbi);
-		goto out;
+		goto out_end;
 	}
 	f2fs_put_dnode(&dn);
 	f2fs_unlock_op(sbi);
@@ -114,9 +116,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)

 out_sem:
 	up_read(&F2FS_I(inode)->i_mmap_sem);
-out:
+out_end:
 	sb_end_pagefault(inode->i_sb);
 	f2fs_update_time(sbi, REQ_TIME);
+out:
 	return block_page_mkwrite_return(err);
 }

-- 


Thanks,

>>
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
>> ---
>>  fs/f2fs/acl.c        |  3 +++
>>  fs/f2fs/checkpoint.c |  1 -
>>  fs/f2fs/file.c       | 23 +++++++++++++++++++++++
>>  fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
>>  fs/f2fs/super.c      |  3 +++
>>  5 files changed, 59 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
>> index f6471f9d707e..a9bf5151e7c2 100644
>> --- a/fs/f2fs/acl.c
>> +++ b/fs/f2fs/acl.c
>> @@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
>>  
>>  int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	return __f2fs_set_acl(inode, type, acl, NULL);
>>  }
>>  
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index 201608281681..6b52d4b66c7b 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
>>  void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
>>  {
>>  	set_ckpt_flags(sbi, CP_ERROR_FLAG);
>> -	sbi->sb->s_flags |= MS_RDONLY;
>>  	if (!end_io)
>>  		f2fs_flush_merged_writes(sbi);
>>  }
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 56232a72d2a3..0e09b9f02dc5 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>>  	struct dnode_of_data dn;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	sb_start_pagefault(inode->i_sb);
>>  
>>  	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
>> @@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
>>  
>>  int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
>> +		return -EIO;
>>  	return f2fs_do_sync_file(file, start, end, datasync, false);
>>  }
>>  
>> @@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
>>  	struct inode *inode = file_inode(file);
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	/* we don't need to use inline_data strictly */
>>  	err = f2fs_convert_inline_inode(inode);
>>  	if (err)
>> @@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
>>  {
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
>>  				S_ISLNK(inode->i_mode)))
>>  		return 0;
>> @@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
>>  	int err;
>>  	bool size_changed = false;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	err = setattr_prepare(dentry, attr);
>>  	if (err)
>>  		return err;
>> @@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
>>  	struct inode *inode = file_inode(file);
>>  	long ret = 0;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	/* f2fs only support ->fallocate for regular file */
>>  	if (!S_ISREG(inode->i_mode))
>>  		return -EINVAL;
>> @@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
>>  
>>  long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
>> +		return -EIO;
>> +
>>  	switch (cmd) {
>>  	case F2FS_IOC_GETFLAGS:
>>  		return f2fs_ioc_getflags(filp, arg);
>> @@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
>>  	struct blk_plug plug;
>>  	ssize_t ret;
>>  
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
>> +		return -EIO;
>> +
>>  	inode_lock(inode);
>>  	ret = generic_write_checks(iocb, from);
>>  	if (ret > 0) {
>> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
>> index e6f86d5d97b9..944f7a6940b6 100644
>> --- a/fs/f2fs/namei.c
>> +++ b/fs/f2fs/namei.c
>> @@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
>>  	nid_t ino = 0;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
>>  	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if (f2fs_encrypted_inode(dir) &&
>>  			!fscrypt_has_permitted_context(dir, inode))
>>  		return -EPERM;
>> @@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
>>  
>>  	trace_f2fs_unlink_enter(dir, dentry);
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
>>  	struct fscrypt_symlink_data *sd = NULL;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if (f2fs_encrypted_inode(dir)) {
>>  		err = fscrypt_get_encryption_info(dir);
>>  		if (err)
>> @@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  	struct inode *inode;
>>  	int err;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
>>  	struct inode *inode;
>>  	int err = 0;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	err = dquot_initialize(dir);
>>  	if (err)
>>  		return err;
>> @@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
>>  
>>  static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
>> +		return -EIO;
>> +
>>  	if (f2fs_encrypted_inode(dir)) {
>>  		int err = fscrypt_get_encryption_info(dir);
>>  		if (err)
>> @@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>>  
>>  static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
>>  {
>> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
>> +		return -EIO;
>> +
>>  	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
>>  }
>>  
>> @@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
>>  	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
>>  	int err = -ENOENT;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if ((f2fs_encrypted_inode(old_dir) &&
>>  			!fscrypt_has_encryption_key(old_dir)) ||
>>  			(f2fs_encrypted_inode(new_dir) &&
>> @@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>>  	int old_nlink = 0, new_nlink = 0;
>>  	int err = -ENOENT;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return -EIO;
>> +
>>  	if ((f2fs_encrypted_inode(old_dir) &&
>>  			!fscrypt_has_encryption_key(old_dir)) ||
>>  			(f2fs_encrypted_inode(new_dir) &&
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 7659b348582a..213d2c1e5759 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
>>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
>>  	int err = 0;
>>  
>> +	if (unlikely(f2fs_cp_error(sbi)))
>> +		return 0;
>> +
>>  	trace_f2fs_sync_fs(sb, sync);
>>  
>>  	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
>>
> 
> 
> ------------------------------------------------------------------------------
> 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
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [f2fs-dev] [PATCH 2/2] f2fs: stop all the operations by cp_error flag
  2017-11-05  3:39       ` Chao Yu
@ 2017-11-06  0:49         ` Jaegeuk Kim
  -1 siblings, 0 replies; 18+ messages in thread
From: Jaegeuk Kim @ 2017-11-06  0:49 UTC (permalink / raw)
  To: Chao Yu; +Cc: Chao Yu, linux-kernel, linux-fsdevel, linux-f2fs-devel

On 11/05, Chao Yu wrote:
> Hi Jaegeuk,
> 
> On 2017/10/24 17:51, Chao Yu wrote:
> > On 2017/10/24 6:14, Jaegeuk Kim wrote:
> >> This patch replaces to use cp_error flag instead of RDONLY for quota off.
> 
> We should convert error number with block_page_mkwrite_return in .page_mkwrite,
> otherwise generic/019 will cause a deadlock issue with below kernel message
> printed:

Fixed. :)
Thanks,

> 
> ============================================
> WARNING: possible recursive locking detected
> 4.14.0-rc1 #35 Tainted: G        W  O
> --------------------------------------------
> fio/5845 is trying to acquire lock:
>  (&mm->mmap_sem){++++}, at: [<c104be02>] __do_page_fault+0x482/0x510
> 
> but task is already holding lock:
>  (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510
> 
> other info that might help us debug this:
>  Possible unsafe locking scenario:
> 
>        CPU0
>        ----
>   lock(&mm->mmap_sem);
>   lock(&mm->mmap_sem);
> 
>  *** DEADLOCK ***
> 
>  May be due to missing lock nesting notation
> 
> 1 lock held by fio/5845:
>  #0:  (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510
> 
> stack backtrace:
> CPU: 3 PID: 5845 Comm: fio Tainted: G        W  O    4.14.0-rc1 #35
> Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
> Call Trace:
>  dump_stack+0x5f/0x92
>  __lock_acquire+0x1019/0x12c0
>  lock_acquire+0xae/0x220
>  down_read+0x38/0x60
>  __do_page_fault+0x482/0x510
>  do_page_fault+0x26/0x290
>  common_exception+0x64/0x6a
> 
> 
> ---
>  fs/f2fs/file.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index e67f03546391..0ce1e82591d1 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -53,8 +53,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>  	struct dnode_of_data dn;
>  	int err;
> 
> -	if (unlikely(f2fs_cp_error(sbi)))
> -		return -EIO;
> +	if (unlikely(f2fs_cp_error(sbi))) {
> +		err = -EIO;
> +		goto out;
> +	}
> 
>  	sb_start_pagefault(inode->i_sb);
> 
> @@ -66,7 +68,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>  	err = f2fs_reserve_block(&dn, page->index);
>  	if (err) {
>  		f2fs_unlock_op(sbi);
> -		goto out;
> +		goto out_end;
>  	}
>  	f2fs_put_dnode(&dn);
>  	f2fs_unlock_op(sbi);
> @@ -114,9 +116,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
> 
>  out_sem:
>  	up_read(&F2FS_I(inode)->i_mmap_sem);
> -out:
> +out_end:
>  	sb_end_pagefault(inode->i_sb);
>  	f2fs_update_time(sbi, REQ_TIME);
> +out:
>  	return block_page_mkwrite_return(err);
>  }
> 
> -- 
> 
> 
> Thanks,
> 
> >>
> >> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > 
> > Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > 
> > Thanks,
> > 
> >> ---
> >>  fs/f2fs/acl.c        |  3 +++
> >>  fs/f2fs/checkpoint.c |  1 -
> >>  fs/f2fs/file.c       | 23 +++++++++++++++++++++++
> >>  fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
> >>  fs/f2fs/super.c      |  3 +++
> >>  5 files changed, 59 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> >> index f6471f9d707e..a9bf5151e7c2 100644
> >> --- a/fs/f2fs/acl.c
> >> +++ b/fs/f2fs/acl.c
> >> @@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
> >>  
> >>  int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	return __f2fs_set_acl(inode, type, acl, NULL);
> >>  }
> >>  
> >> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> >> index 201608281681..6b52d4b66c7b 100644
> >> --- a/fs/f2fs/checkpoint.c
> >> +++ b/fs/f2fs/checkpoint.c
> >> @@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
> >>  void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
> >>  {
> >>  	set_ckpt_flags(sbi, CP_ERROR_FLAG);
> >> -	sbi->sb->s_flags |= MS_RDONLY;
> >>  	if (!end_io)
> >>  		f2fs_flush_merged_writes(sbi);
> >>  }
> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> >> index 56232a72d2a3..0e09b9f02dc5 100644
> >> --- a/fs/f2fs/file.c
> >> +++ b/fs/f2fs/file.c
> >> @@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
> >>  	struct dnode_of_data dn;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	sb_start_pagefault(inode->i_sb);
> >>  
> >>  	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
> >> @@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
> >>  
> >>  int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
> >> +		return -EIO;
> >>  	return f2fs_do_sync_file(file, start, end, datasync, false);
> >>  }
> >>  
> >> @@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
> >>  	struct inode *inode = file_inode(file);
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	/* we don't need to use inline_data strictly */
> >>  	err = f2fs_convert_inline_inode(inode);
> >>  	if (err)
> >> @@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
> >>  {
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
> >>  				S_ISLNK(inode->i_mode)))
> >>  		return 0;
> >> @@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> >>  	int err;
> >>  	bool size_changed = false;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	err = setattr_prepare(dentry, attr);
> >>  	if (err)
> >>  		return err;
> >> @@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
> >>  	struct inode *inode = file_inode(file);
> >>  	long ret = 0;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	/* f2fs only support ->fallocate for regular file */
> >>  	if (!S_ISREG(inode->i_mode))
> >>  		return -EINVAL;
> >> @@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
> >>  
> >>  long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
> >> +		return -EIO;
> >> +
> >>  	switch (cmd) {
> >>  	case F2FS_IOC_GETFLAGS:
> >>  		return f2fs_ioc_getflags(filp, arg);
> >> @@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
> >>  	struct blk_plug plug;
> >>  	ssize_t ret;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	inode_lock(inode);
> >>  	ret = generic_write_checks(iocb, from);
> >>  	if (ret > 0) {
> >> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> >> index e6f86d5d97b9..944f7a6940b6 100644
> >> --- a/fs/f2fs/namei.c
> >> +++ b/fs/f2fs/namei.c
> >> @@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
> >>  	nid_t ino = 0;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
> >>  	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if (f2fs_encrypted_inode(dir) &&
> >>  			!fscrypt_has_permitted_context(dir, inode))
> >>  		return -EPERM;
> >> @@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
> >>  
> >>  	trace_f2fs_unlink_enter(dir, dentry);
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
> >>  	struct fscrypt_symlink_data *sd = NULL;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if (f2fs_encrypted_inode(dir)) {
> >>  		err = fscrypt_get_encryption_info(dir);
> >>  		if (err)
> >> @@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
> >>  	struct inode *inode;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
> >>  	struct inode *inode;
> >>  	int err = 0;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
> >>  
> >>  static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> >> +		return -EIO;
> >> +
> >>  	if (f2fs_encrypted_inode(dir)) {
> >>  		int err = fscrypt_get_encryption_info(dir);
> >>  		if (err)
> >> @@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
> >>  
> >>  static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> >> +		return -EIO;
> >> +
> >>  	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
> >>  }
> >>  
> >> @@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
> >>  	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
> >>  	int err = -ENOENT;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if ((f2fs_encrypted_inode(old_dir) &&
> >>  			!fscrypt_has_encryption_key(old_dir)) ||
> >>  			(f2fs_encrypted_inode(new_dir) &&
> >> @@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
> >>  	int old_nlink = 0, new_nlink = 0;
> >>  	int err = -ENOENT;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if ((f2fs_encrypted_inode(old_dir) &&
> >>  			!fscrypt_has_encryption_key(old_dir)) ||
> >>  			(f2fs_encrypted_inode(new_dir) &&
> >> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> >> index 7659b348582a..213d2c1e5759 100644
> >> --- a/fs/f2fs/super.c
> >> +++ b/fs/f2fs/super.c
> >> @@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
> >>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
> >>  	int err = 0;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return 0;
> >> +
> >>  	trace_f2fs_sync_fs(sb, sync);
> >>  
> >>  	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
> >>
> > 
> > 
> > ------------------------------------------------------------------------------
> > 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
> > 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/2] f2fs: stop all the operations by cp_error flag
@ 2017-11-06  0:49         ` Jaegeuk Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Jaegeuk Kim @ 2017-11-06  0:49 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

On 11/05, Chao Yu wrote:
> Hi Jaegeuk,
> 
> On 2017/10/24 17:51, Chao Yu wrote:
> > On 2017/10/24 6:14, Jaegeuk Kim wrote:
> >> This patch replaces to use cp_error flag instead of RDONLY for quota off.
> 
> We should convert error number with block_page_mkwrite_return in .page_mkwrite,
> otherwise generic/019 will cause a deadlock issue with below kernel message
> printed:

Fixed. :)
Thanks,

> 
> ============================================
> WARNING: possible recursive locking detected
> 4.14.0-rc1 #35 Tainted: G        W  O
> --------------------------------------------
> fio/5845 is trying to acquire lock:
>  (&mm->mmap_sem){++++}, at: [<c104be02>] __do_page_fault+0x482/0x510
> 
> but task is already holding lock:
>  (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510
> 
> other info that might help us debug this:
>  Possible unsafe locking scenario:
> 
>        CPU0
>        ----
>   lock(&mm->mmap_sem);
>   lock(&mm->mmap_sem);
> 
>  *** DEADLOCK ***
> 
>  May be due to missing lock nesting notation
> 
> 1 lock held by fio/5845:
>  #0:  (&mm->mmap_sem){++++}, at: [<c104ba9e>] __do_page_fault+0x11e/0x510
> 
> stack backtrace:
> CPU: 3 PID: 5845 Comm: fio Tainted: G        W  O    4.14.0-rc1 #35
> Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
> Call Trace:
>  dump_stack+0x5f/0x92
>  __lock_acquire+0x1019/0x12c0
>  lock_acquire+0xae/0x220
>  down_read+0x38/0x60
>  __do_page_fault+0x482/0x510
>  do_page_fault+0x26/0x290
>  common_exception+0x64/0x6a
> 
> 
> ---
>  fs/f2fs/file.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index e67f03546391..0ce1e82591d1 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -53,8 +53,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>  	struct dnode_of_data dn;
>  	int err;
> 
> -	if (unlikely(f2fs_cp_error(sbi)))
> -		return -EIO;
> +	if (unlikely(f2fs_cp_error(sbi))) {
> +		err = -EIO;
> +		goto out;
> +	}
> 
>  	sb_start_pagefault(inode->i_sb);
> 
> @@ -66,7 +68,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
>  	err = f2fs_reserve_block(&dn, page->index);
>  	if (err) {
>  		f2fs_unlock_op(sbi);
> -		goto out;
> +		goto out_end;
>  	}
>  	f2fs_put_dnode(&dn);
>  	f2fs_unlock_op(sbi);
> @@ -114,9 +116,10 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
> 
>  out_sem:
>  	up_read(&F2FS_I(inode)->i_mmap_sem);
> -out:
> +out_end:
>  	sb_end_pagefault(inode->i_sb);
>  	f2fs_update_time(sbi, REQ_TIME);
> +out:
>  	return block_page_mkwrite_return(err);
>  }
> 
> -- 
> 
> 
> Thanks,
> 
> >>
> >> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > 
> > Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > 
> > Thanks,
> > 
> >> ---
> >>  fs/f2fs/acl.c        |  3 +++
> >>  fs/f2fs/checkpoint.c |  1 -
> >>  fs/f2fs/file.c       | 23 +++++++++++++++++++++++
> >>  fs/f2fs/namei.c      | 30 ++++++++++++++++++++++++++++++
> >>  fs/f2fs/super.c      |  3 +++
> >>  5 files changed, 59 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> >> index f6471f9d707e..a9bf5151e7c2 100644
> >> --- a/fs/f2fs/acl.c
> >> +++ b/fs/f2fs/acl.c
> >> @@ -254,6 +254,9 @@ static int __f2fs_set_acl(struct inode *inode, int type,
> >>  
> >>  int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	return __f2fs_set_acl(inode, type, acl, NULL);
> >>  }
> >>  
> >> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> >> index 201608281681..6b52d4b66c7b 100644
> >> --- a/fs/f2fs/checkpoint.c
> >> +++ b/fs/f2fs/checkpoint.c
> >> @@ -29,7 +29,6 @@ struct kmem_cache *inode_entry_slab;
> >>  void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
> >>  {
> >>  	set_ckpt_flags(sbi, CP_ERROR_FLAG);
> >> -	sbi->sb->s_flags |= MS_RDONLY;
> >>  	if (!end_io)
> >>  		f2fs_flush_merged_writes(sbi);
> >>  }
> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> >> index 56232a72d2a3..0e09b9f02dc5 100644
> >> --- a/fs/f2fs/file.c
> >> +++ b/fs/f2fs/file.c
> >> @@ -53,6 +53,9 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
> >>  	struct dnode_of_data dn;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	sb_start_pagefault(inode->i_sb);
> >>  
> >>  	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
> >> @@ -310,6 +313,8 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
> >>  
> >>  int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(file)))))
> >> +		return -EIO;
> >>  	return f2fs_do_sync_file(file, start, end, datasync, false);
> >>  }
> >>  
> >> @@ -446,6 +451,9 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
> >>  	struct inode *inode = file_inode(file);
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	/* we don't need to use inline_data strictly */
> >>  	err = f2fs_convert_inline_inode(inode);
> >>  	if (err)
> >> @@ -632,6 +640,9 @@ int f2fs_truncate(struct inode *inode)
> >>  {
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
> >>  				S_ISLNK(inode->i_mode)))
> >>  		return 0;
> >> @@ -731,6 +742,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> >>  	int err;
> >>  	bool size_changed = false;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	err = setattr_prepare(dentry, attr);
> >>  	if (err)
> >>  		return err;
> >> @@ -1459,6 +1473,9 @@ static long f2fs_fallocate(struct file *file, int mode,
> >>  	struct inode *inode = file_inode(file);
> >>  	long ret = 0;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	/* f2fs only support ->fallocate for regular file */
> >>  	if (!S_ISREG(inode->i_mode))
> >>  		return -EINVAL;
> >> @@ -2637,6 +2654,9 @@ static int f2fs_ioc_fssetxattr(struct file *filp, unsigned long arg)
> >>  
> >>  long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
> >> +		return -EIO;
> >> +
> >>  	switch (cmd) {
> >>  	case F2FS_IOC_GETFLAGS:
> >>  		return f2fs_ioc_getflags(filp, arg);
> >> @@ -2694,6 +2714,9 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
> >>  	struct blk_plug plug;
> >>  	ssize_t ret;
> >>  
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
> >> +		return -EIO;
> >> +
> >>  	inode_lock(inode);
> >>  	ret = generic_write_checks(iocb, from);
> >>  	if (ret > 0) {
> >> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> >> index e6f86d5d97b9..944f7a6940b6 100644
> >> --- a/fs/f2fs/namei.c
> >> +++ b/fs/f2fs/namei.c
> >> @@ -183,6 +183,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
> >>  	nid_t ino = 0;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -227,6 +230,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
> >>  	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if (f2fs_encrypted_inode(dir) &&
> >>  			!fscrypt_has_permitted_context(dir, inode))
> >>  		return -EPERM;
> >> @@ -426,6 +432,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
> >>  
> >>  	trace_f2fs_unlink_enter(dir, dentry);
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -481,6 +490,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
> >>  	struct fscrypt_symlink_data *sd = NULL;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if (f2fs_encrypted_inode(dir)) {
> >>  		err = fscrypt_get_encryption_info(dir);
> >>  		if (err)
> >> @@ -587,6 +599,9 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
> >>  	struct inode *inode;
> >>  	int err;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -639,6 +654,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
> >>  	struct inode *inode;
> >>  	int err = 0;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	err = dquot_initialize(dir);
> >>  	if (err)
> >>  		return err;
> >> @@ -733,6 +751,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
> >>  
> >>  static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> >> +		return -EIO;
> >> +
> >>  	if (f2fs_encrypted_inode(dir)) {
> >>  		int err = fscrypt_get_encryption_info(dir);
> >>  		if (err)
> >> @@ -744,6 +765,9 @@ static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
> >>  
> >>  static int f2fs_create_whiteout(struct inode *dir, struct inode **whiteout)
> >>  {
> >> +	if (unlikely(f2fs_cp_error(F2FS_I_SB(dir))))
> >> +		return -EIO;
> >> +
> >>  	return __f2fs_tmpfile(dir, NULL, S_IFCHR | WHITEOUT_MODE, whiteout);
> >>  }
> >>  
> >> @@ -763,6 +787,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
> >>  	bool is_old_inline = f2fs_has_inline_dentry(old_dir);
> >>  	int err = -ENOENT;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if ((f2fs_encrypted_inode(old_dir) &&
> >>  			!fscrypt_has_encryption_key(old_dir)) ||
> >>  			(f2fs_encrypted_inode(new_dir) &&
> >> @@ -956,6 +983,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
> >>  	int old_nlink = 0, new_nlink = 0;
> >>  	int err = -ENOENT;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return -EIO;
> >> +
> >>  	if ((f2fs_encrypted_inode(old_dir) &&
> >>  			!fscrypt_has_encryption_key(old_dir)) ||
> >>  			(f2fs_encrypted_inode(new_dir) &&
> >> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> >> index 7659b348582a..213d2c1e5759 100644
> >> --- a/fs/f2fs/super.c
> >> +++ b/fs/f2fs/super.c
> >> @@ -885,6 +885,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
> >>  	struct f2fs_sb_info *sbi = F2FS_SB(sb);
> >>  	int err = 0;
> >>  
> >> +	if (unlikely(f2fs_cp_error(sbi)))
> >> +		return 0;
> >> +
> >>  	trace_f2fs_sync_fs(sb, sync);
> >>  
> >>  	if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
> >>
> > 
> > 
> > ------------------------------------------------------------------------------
> > 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
> > 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-11-06  0:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-23 22:14 [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl Jaegeuk Kim
2017-10-23 22:14 ` Jaegeuk Kim
2017-10-23 22:14 ` [PATCH 2/2] f2fs: stop all the operations by cp_error flag Jaegeuk Kim
2017-10-24  9:51   ` [f2fs-dev] " Chao Yu
2017-10-24  9:51     ` Chao Yu
2017-11-05  3:39     ` Chao Yu
2017-11-05  3:39       ` Chao Yu
2017-11-06  0:49       ` [f2fs-dev] " Jaegeuk Kim
2017-11-06  0:49         ` Jaegeuk Kim
2017-10-24  9:46 ` [PATCH 1/2] f2fs: add missing quota_initialize in f2fs_set_acl Chao Yu
2017-10-24  9:46   ` Chao Yu
2017-10-25  5:44   ` Jaegeuk Kim
2017-10-25  5:57     ` Chao Yu
2017-10-25  5:57       ` Chao Yu
2017-10-25  6:30       ` Jaegeuk Kim
2017-10-25 15:47         ` [f2fs-dev] " Chao Yu
2017-10-25 15:47           ` Chao Yu
2017-10-25  5:43 ` [PATCH 1/2 v2] " Jaegeuk Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.