Skip to contentSkip to conversation

erofs: misc fixes for erofs in fscache mode

PATCH In review Jingbo Xu 4 participants 8 messages Nov 4, 2022 – Nov 8, 2022 EROFS file system

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

cover erofs: misc fixes for erofs in fscache mode

There are several minor fixes for the data path of the fscache mode.

Jingbo Xu (2):
erofs: put metabuf in error path in fscache mode
erofs: get correct count for unmapped range in fscache mode

 fs/erofs/fscache.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.19.1.6.gb485710b
author
#1 lore raw

PATCH 1/2 erofs: put metabuf in error path in fscache mode

For tail packing layout, put metabuf when error is encountered.

Fixes 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
---
 fs/erofs/fscache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/erofs/fscache.c +3 -1
index fe05bc51f9f2..83559008bfa8 100644
@@ -287,8 +287,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
 			return PTR_ERR(src);
 
 		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
-		if (copy_to_iter(src + offset, size, &iter) != size)
+		if (copy_to_iter(src + offset, size, &iter) != size) {
+			erofs_put_metabuf(&buf);
 			return -EFAULT;
+		}
 		iov_iter_zero(PAGE_SIZE - size, &iter);
 		erofs_put_metabuf(&buf);
 		return PAGE_SIZE;
Signature · 1 line
2.19.1.6.gb485710b
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] erofs: put metabuf in error path in fscache mode

Quoted 4 lines · Jingbo Xu

For tail packing layout, put metabuf when error is encountered.

Fixes 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")

Thanks,
Gao Xiang

Quoted 22 lines
---
 fs/erofs/fscache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/erofs/fscache.c +3 -1
index fe05bc51f9f2..83559008bfa8 100644
@@ -287,8 +287,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
 			return PTR_ERR(src);
 
 		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
-		if (copy_to_iter(src + offset, size, &iter) != size)
+		if (copy_to_iter(src + offset, size, &iter) != size) {
+			erofs_put_metabuf(&buf);
 			return -EFAULT;
+		}
 		iov_iter_zero(PAGE_SIZE - size, &iter);
 		erofs_put_metabuf(&buf);
 		return PAGE_SIZE;
Signature · 1 line
2.19.1.6.gb485710b
Reviewed-by on v1 1/2
#3 lore raw

Re: [External] [PATCH 1/2] erofs: put metabuf in error path in fscache mode

In reply to Jingbo Xu
Quoted 4 lines · Jingbo Xu

For tail packing layout, put metabuf when error is encountered.

Fixes 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
Quoted 20 lines
---
  fs/erofs/fscache.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
fs/erofs/fscache.c +3 -1
index fe05bc51f9f2..83559008bfa8 100644
@@ -287,8 +287,10 @@ static int erofs_fscache_data_read(struct address_space *mapping,
  			return PTR_ERR(src);
 
  		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, PAGE_SIZE);
-		if (copy_to_iter(src + offset, size, &iter) != size)
+		if (copy_to_iter(src + offset, size, &iter) != size) {
+			erofs_put_metabuf(&buf);
  			return -EFAULT;
+		}
  		iov_iter_zero(PAGE_SIZE - size, &iter);
  		erofs_put_metabuf(&buf);
  		return PAGE_SIZE;
author
#5 lore raw

PATCH 2/2 erofs: get correct count for unmapped range in fscache mode

In reply to Jingbo Xu

For unmapped range, the returned map.m_llen is zero, and thus the calculated count is unexpected zero.

Prior to the refactoring introduced by commit 1ae9470c3e14 ("erofs:
clean up .read_folio() and .readahead() in fscache mode"), only the readahead routine suffers from this. With the refactoring of making .read_folio() and .readahead() calling one common routine, both read_folio and readahead have this issue now.

Fix this by calculating count separately in unmapped condition.

Fixes c665b394b9e8 ("erofs: implement fscache-based data readahead")
Fixes 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")
---
 fs/erofs/fscache.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/erofs/fscache.c +4 -3
index 83559008bfa8..260fa4737fc0 100644
@@ -296,15 +296,16 @@ static int erofs_fscache_data_read(struct address_space *mapping,
 		return PAGE_SIZE;
 	}
 
-	count = min_t(size_t, map.m_llen - (pos - map.m_la), len);
-	DBG_BUGON(!count || count % PAGE_SIZE);
-
 	if (!(map.m_flags & EROFS_MAP_MAPPED)) {
+		count = len;
 		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count);
 		iov_iter_zero(count, &iter);
 		return count;
 	}
 
+	count = min_t(size_t, map.m_llen - (pos - map.m_la), len);
+	DBG_BUGON(!count || count % PAGE_SIZE);
+
 	mdev = (struct erofs_map_dev) {
 		.m_deviceid = map.m_deviceid,
 		.m_pa = map.m_pa,
Signature · 1 line
2.19.1.6.gb485710b
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] erofs: get correct count for unmapped range in fscache mode

Quoted 9 lines · Jingbo Xu

For unmapped range, the returned map.m_llen is zero, and thus the calculated count is unexpected zero.

Prior to the refactoring introduced by commit 1ae9470c3e14 ("erofs:
clean up .read_folio() and .readahead() in fscache mode"), only the readahead routine suffers from this. With the refactoring of making .read_folio() and .readahead() calling one common routine, both read_folio and readahead have this issue now.

Quoted 5 lines

Fix this by calculating count separately in unmapped condition.

Fixes c665b394b9e8 ("erofs: implement fscache-based data readahead")
Fixes 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")

Thanks,
Gao Xiang

Quoted 30 lines
---
 fs/erofs/fscache.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/erofs/fscache.c +4 -3
index 83559008bfa8..260fa4737fc0 100644
@@ -296,15 +296,16 @@ static int erofs_fscache_data_read(struct address_space *mapping,
 		return PAGE_SIZE;
 	}
 
-	count = min_t(size_t, map.m_llen - (pos - map.m_la), len);
-	DBG_BUGON(!count || count % PAGE_SIZE);
-
 	if (!(map.m_flags & EROFS_MAP_MAPPED)) {
+		count = len;
 		iov_iter_xarray(&iter, READ, &mapping->i_pages, pos, count);
 		iov_iter_zero(count, &iter);
 		return count;
 	}
 
+	count = min_t(size_t, map.m_llen - (pos - map.m_la), len);
+	DBG_BUGON(!count || count % PAGE_SIZE);
+
 	mdev = (struct erofs_map_dev) {
 		.m_deviceid = map.m_deviceid,
 		.m_pa = map.m_pa,
Signature · 1 line
2.19.1.6.gb485710b
maintainer Reviewed-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] erofs: get correct count for unmapped range in fscache mode

In reply to Jingbo Xu
Quoted 9 lines · Jingbo Xu

For unmapped range, the returned map.m_llen is zero, and thus the calculated count is unexpected zero.

Prior to the refactoring introduced by commit 1ae9470c3e14 ("erofs:
clean up .read_folio() and .readahead() in fscache mode"), only the readahead routine suffers from this. With the refactoring of making .read_folio() and .readahead() calling one common routine, both read_folio and readahead have this issue now.

Quoted 5 lines

Fix this by calculating count separately in unmapped condition.

Fixes c665b394b9e8 ("erofs: implement fscache-based data readahead")
Fixes 1ae9470c3e14 ("erofs: clean up .read_folio() and .readahead() in fscache mode")

Thanks,