Skip to contentSkip to conversation

f2fs: fix quota_sync failure due to f2fs_lock_op

PATCH In review Jaegeuk Kim 2 participants 8 messages Apr 9, 2020 – Apr 24, 2020 F2FS file system

lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: fix quota_sync failure due to f2fs_lock_op

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/data.c +2 -2
index 358c5f0bd6346..1139d8cf4b8d1 100644
@@ -2707,8 +2707,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;
Signature · 1 line
2.26.0.110.g2183baf09c-goog
#1 lore raw
Quoted 15 lines · Jaegeuk Kim

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
 fs/f2fs/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/f2fs/data.c +0 -0
index 358c5f0bd6346..1139d8cf4b8d1 100644

fs/f2fs/data.c int f2fs_write_single_data_page(struct page *page, int *submitted, · line 2711

Quoted 7 lines
fs/f2fs/data.c +2 -2
@@ -2707,8 +2707,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {

Should cover multipage write path, in the case of normal quota file (such as /quota.user or /quota.group) is set as compressed.

Thanks,

fs/f2fs/data.c int f2fs_write_single_data_page(struct page *page, int *submitted, · line 2714

Quoted 4 lines
fs/f2fs/data.c +0 -0
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#2 lore raw

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
v2:
- fix multipage write case

 fs/f2fs/compress.c | 2 +-
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +1 -1
index df7b2d15eacde..faaa358289010 100644
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;
 
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
fs/f2fs/data.c +2 -2
index accd28728642a..5c8d3823d7593 100644
@@ -2656,8 +2656,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
Reviewed-by
#3 lore raw
Quoted 6 lines · Jaegeuk Kim

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

Thanks,

#4 lore raw
In reply to Jaegeuk Kim
Quoted 19 lines · Jaegeuk Kim

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
v2:
- fix multipage write case

 fs/f2fs/compress.c | 2 +-
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +0 -0
index df7b2d15eacde..faaa358289010 100644

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 989

Quoted 6 lines
fs/f2fs/compress.c +1 -1
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;

I encounter deadlock..

Should call f2fs_unlock_op() for non-quota compressed inode later.

Thanks,

Quoted 18 lines
fs/f2fs/compress.c +0 -0
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
fs/f2fs/data.c +2 -2
index accd28728642a..5c8d3823d7593 100644
@@ -2656,8 +2656,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;
author maintainer
#5 lore raw
Quoted 23 lines · Chao Yu
Quoted 22 lines · Jaegeuk Kim

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
v2:
- fix multipage write case

 fs/f2fs/compress.c | 2 +-
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +0 -0
index df7b2d15eacde..faaa358289010 100644
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
Quoted 7 lines

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 989

Quoted 3 lines
fs/f2fs/compress.c +1 -1
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;

I encounter deadlock..

Should call f2fs_unlock_op() for non-quota compressed inode later.

Could you elaborate a bit?

Quoted 21 lines

Thanks,

Quoted 18 lines
fs/f2fs/compress.c +0 -0
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
fs/f2fs/data.c +2 -2
index accd28728642a..5c8d3823d7593 100644
@@ -2656,8 +2656,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;
Reviewed-by
#6 lore raw
Quoted 30 lines · Jaegeuk Kim
Quoted 29 lines · Chao Yu
Quoted 19 lines · Jaegeuk Kim

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
v2:
- fix multipage write case

 fs/f2fs/compress.c | 2 +-
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +0 -0
index df7b2d15eacde..faaa358289010 100644

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 989

Quoted 6 lines
fs/f2fs/compress.c +1 -1
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;

I encounter deadlock..

Quoted 3 lines
Quoted 1 line

Should call f2fs_unlock_op() for non-quota compressed inode later.

Could you elaborate a bit?

I meant we need to change as below, otherwise, cp_rwsem can be negative after f2fs_unlock_op if writebacked datas are belong to compressed quota file.

From 817dc629c47d3000c595640ecb3099b880519d47 Mon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Thu, 9 Apr 2020 10:25:21 -0700
Subject: [PATCH] f2fs: fix quota_sync failure due to f2fs_lock_op

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
 fs/f2fs/compress.c | 8 +++++---
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/compress.c +5 -3
index df7b2d15eacd..26b071afe48a 100644
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;
 
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
@@ -1092,7 +1092,8 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 		set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN);
 
 	f2fs_put_dnode(&dn);
-	f2fs_unlock_op(sbi);
+	if (!IS_NOQUOTA(inode))
+		f2fs_unlock_op(sbi);
 
 	spin_lock(&fi->i_size_lock);
 	if (fi->last_disk_size < psize)
@@ -1118,7 +1119,8 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 out_put_dnode:
 	f2fs_put_dnode(&dn);
 out_unlock_op:
-	f2fs_unlock_op(sbi);
+	if (!IS_NOQUOTA(inode))
+		f2fs_unlock_op(sbi);
 	return -EAGAIN;
 }
 
fs/f2fs/data.c +2 -2
index 8dd48c5b6c0d..dd439dbb134d 100644
@@ -2660,8 +2660,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;
Signature · 1 line
2.18.0.rc1
Quoted 24 lines
Quoted 14 lines

Thanks,

Quoted 10 lines
fs/f2fs/compress.c +0 -0
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
fs/f2fs/data.c +0 -0
index accd28728642a..5c8d3823d7593 100644
@@ -2656,8 +2656,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
Quoted 8 lines

fs/f2fs/data.c int f2fs_write_single_data_page(struct page *page, int *submitted, · line 2663

Quoted 8 lines
fs/f2fs/data.c +2 -2
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;

.

author maintainer
#7 lore raw
Quoted 31 lines · Chao Yu
Quoted 30 lines · Jaegeuk Kim
Quoted 29 lines · Chao Yu
Quoted 19 lines · Jaegeuk Kim

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
v2:
- fix multipage write case

 fs/f2fs/compress.c | 2 +-
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +0 -0
index df7b2d15eacde..faaa358289010 100644

fs/f2fs/compress.c static int f2fs_write_compressed_pages(struct compress_ctx *cc, · line 989

Quoted 6 lines
fs/f2fs/compress.c +1 -1
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;

I encounter deadlock..

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Should call f2fs_unlock_op() for non-quota compressed inode later.

Could you elaborate a bit?

I meant we need to change as below, otherwise, cp_rwsem can be negative after f2fs_unlock_op if writebacked datas are belong to compressed quota file.

Ah, I see. Fixed.

Thanks,

Quoted 95 lines
Quoted 2 lines

From 817dc629c47d3000c595640ecb3099b880519d47 Mon Sep 17 00:00:00 2001

From: Jaegeuk Kim <[email protected]>
Date: Thu, 9 Apr 2020 10:25:21 -0700
Subject: [PATCH] f2fs: fix quota_sync failure due to f2fs_lock_op

f2fs_quota_sync() uses f2fs_lock_op() before flushing dirty pages, but f2fs_write_data_page() returns EAGAIN.
Likewise dentry blocks, we can just bypass getting the lock, since quota blocks are also maintained by checkpoint.

---
 fs/f2fs/compress.c | 8 +++++---
 fs/f2fs/data.c     | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/compress.c +5 -3
index df7b2d15eacd..26b071afe48a 100644
@@ -985,7 +985,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	loff_t psize;
 	int i, err;
 
-	if (!f2fs_trylock_op(sbi))
+	if (!IS_NOQUOTA(inode) && !f2fs_trylock_op(sbi))
 		return -EAGAIN;
 
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
@@ -1092,7 +1092,8 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 		set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN);
 
 	f2fs_put_dnode(&dn);
-	f2fs_unlock_op(sbi);
+	if (!IS_NOQUOTA(inode))
+		f2fs_unlock_op(sbi);
 
 	spin_lock(&fi->i_size_lock);
 	if (fi->last_disk_size < psize)
@@ -1118,7 +1119,8 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 out_put_dnode:
 	f2fs_put_dnode(&dn);
 out_unlock_op:
-	f2fs_unlock_op(sbi);
+	if (!IS_NOQUOTA(inode))
+		f2fs_unlock_op(sbi);
 	return -EAGAIN;
 }
 
fs/f2fs/data.c +2 -2
index 8dd48c5b6c0d..dd439dbb134d 100644
@@ -2660,8 +2660,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;
Signature · 1 line
2.18.0.rc1
Quoted 24 lines
Quoted 14 lines

Thanks,

Quoted 10 lines
fs/f2fs/compress.c +0 -0
 	set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
fs/f2fs/data.c +0 -0
index accd28728642a..5c8d3823d7593 100644
@@ -2656,8 +2656,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,
 			f2fs_available_free_memory(sbi, BASE_CHECK))))
 		goto redirty_out;
 
Quoted 8 lines

fs/f2fs/data.c int f2fs_write_single_data_page(struct page *page, int *submitted, · line 2667

Quoted 8 lines
fs/f2fs/data.c +2 -2
-	/* Dentry blocks are controlled by checkpoint */
-	if (S_ISDIR(inode->i_mode)) {
+	/* Dentry/quota blocks are controlled by checkpoint */
+	if (S_ISDIR(inode->i_mode) || IS_NOQUOTA(inode)) {
 		fio.need_lock = LOCK_DONE;
 		err = f2fs_do_write_data_page(&fio);
 		goto done;

.