f2fs: change the way of handling range.len in F2FS_IOC_SEC_TRIM_FILE
PATCH 1/1 f2fs: change the way of handling range.len in F2FS_IOC_SEC_TRIM_FILE
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from making end_addr zero and triggering different behaviour of the function.
--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
fs/f2fs/file.c +7 -9
@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - } -if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size; +else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||
Signature · 1 line
2.27.0.383.g050319c2ae-goog
Jaegeuk Kim
maintainerQuoted 33 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-3@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 )
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 10 lines
fs/f2fs/file.c +2
-6goto err; - } -if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;
Hmm, what if there are blocks beyond i_size? Do we need to check i_blocks for ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
1. The valid data will be within i_size.
2. All the trim operations will be done in a unit of block, even if i_size is not aligned with BLKSIZE like the below.
index = F2FS_BYTES_TO_BLK(range.start);
pg_end = DIV_ROUND_UP(end_addr, F2FS_BLKSIZE); <= BLKSIZE aligned
Are you worried about the case that sudden power-off occurs while a file is being truncated?
ex) 1GB file is being truncated to 4KB -> sudden power-off -> i_size(4KB), i_blocks(maybe somewhere between 4KB and 1GB)
2020년 7월 10일 (금) 오후 12:02, Jaegeuk Kim <[email protected]>님이 작성:
Quoted 63 lines · Daeho Jeong
Quoted 33 lines
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-3@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 )fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 10 lines
fs/f2fs/file.c +2
-6goto err; - } -if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksfor ending criteria?Quoted 14 lines
fs/f2fs/file.c +2
-1+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) || --2.27.0.383.g050319c2ae-goog
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 11 lines · Daeho Jeong
1. The valid data will be within
i_size.
2. All the trim operations will be done in a unit of block, even ifi_sizeis not aligned with BLKSIZE like the below.index =
F2FS_BYTES_TO_BLK(range.start);
pg_end=DIV_ROUND_UP(end_addr, F2FS_BLKSIZE); <= BLKSIZE alignedAre you worried about the case that sudden power-off occurs while a file is being truncated?
ex) 1GB file is being truncated to 4KB -> sudden power-off ->i_size(4KB),i_blocks(maybe somewhere between 4KB and 1GB)
Yes. Basically, I believe we can have some data beyond i_size like fsverity.
Quoted 65 lines
2020년 7월 10일 (금) 오후 12:02, Jaegeuk Kim <[email protected]>님이 작성:
Quoted 63 lines · Daeho Jeong
Quoted 33 lines
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-3@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 )fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 10 lines
fs/f2fs/file.c +2
-6goto err; - } -if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksfor ending criteria?Quoted 14 lines
fs/f2fs/file.c +2
-1+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) || --2.27.0.383.g050319c2ae-goog
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 8 lines · Jaegeuk Kim
Quoted 7 lines · Daeho Jeong
1. The valid data will be within
i_size.
2. All the trim operations will be done in a unit of block, even ifi_sizeis not aligned with BLKSIZE like the below.index =
F2FS_BYTES_TO_BLK(range.start);
pg_end=DIV_ROUND_UP(end_addr, F2FS_BLKSIZE); <= BLKSIZE aligned
Quoted 7 lines
Quoted 4 lines
Are you worried about the case that sudden power-off occurs while a file is being truncated?
ex) 1GB file is being truncated to 4KB -> sudden power-off ->i_size(4KB),i_blocks(maybe somewhere between 4KB and 1GB)Yes. Basically, I believe we can have some data beyond
i_sizelike fsverity.
Note that fs-verity files are read-only, and therefore this ioctl can't be used on them (since it requires a writable file descriptor). So that case doesn't need to be handled here.
- Eric
Jaegeuk Kim
maintainerQuoted 14 lines · Eric Biggers
Quoted 13 lines · Jaegeuk Kim
Quoted 11 lines · Daeho Jeong
1. The valid data will be within
i_size.
2. All the trim operations will be done in a unit of block, even ifi_sizeis not aligned with BLKSIZE like the below.index =
F2FS_BYTES_TO_BLK(range.start);
pg_end=DIV_ROUND_UP(end_addr, F2FS_BLKSIZE); <= BLKSIZE alignedAre you worried about the case that sudden power-off occurs while a file is being truncated?
ex) 1GB file is being truncated to 4KB -> sudden power-off ->i_size(4KB),i_blocks(maybe somewhere between 4KB and 1GB)
Quoted 6 lines
Quoted 2 lines
Yes. Basically, I believe we can have some data beyond
i_sizelike fsverity.Note that fs-verity files are read-only, and therefore this ioctl can't be used on them (since it requires a writable file descriptor). So that case doesn't need to be handled here.
I meant it as an example of valid data beyond i_size.
Quoted 2 lines
- Eric
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }
Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;
We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 2 lines
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksfor
The blocks beyond i_size will never be written, there won't be any valid message there, so we don't need to worry about that.
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
Jaegeuk Kim
maintainerQuoted 50 lines · Chao Yu
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 1 line
Quoted 4 lines
Quoted 1 line
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.
I don't think we have a way to guarantee the order of i_size and block allocation in f2fs. See f2fs_write_begin and f2fs_write_end.
Quoted 27 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
Quoted 51 lines · Jaegeuk Kim
Quoted 50 lines · Chao Yu
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.I don't think we have a way to guarantee the order of
i_sizeand block allocation in f2fs. Seef2fs_write_beginandf2fs_write_end.
However, write_begin & write_end are covered by inode_lock, it could not be racy with inode size check in f2fs_sec_trim_file() as it hold inode_lock as well?
Quoted 30 lines
Quoted 28 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
..
Jaegeuk Kim
maintainerQuoted 57 lines · Chao Yu
Quoted 56 lines · Jaegeuk Kim
Quoted 54 lines · Chao Yu
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 2 lines
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.
Quoted 6 lines
Quoted 2 lines
I don't think we have a way to guarantee the order of
i_sizeand block allocation in f2fs. Seef2fs_write_beginandf2fs_write_end.However,
write_begin&write_endare covered byinode_lock, it could not be racy with inode size check inf2fs_sec_trim_file()as it holdinode_lockas well?
Like Daeho said, write_begin -> checkpoint -> power-cut can give bigger i_blocks than i_size.
Quoted 31 lines
Quoted 31 lines
Quoted 29 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
..
To handle that case, I think we need to handle range.len(-1) differently. When range.len is -1, we need to find out every block belongs to the inode regardless of i_size and discard it.
2020년 7월 10일 (금) 오후 12:52, Jaegeuk Kim <[email protected]>님이 작성:
Quoted 62 lines · Chao Yu
Quoted 60 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
Quoted 50 lines · Jaegeuk Kim
Quoted 37 lines · Daeho Jeong
Quoted 36 lines
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 1 line
Quoted 4 lines
Quoted 1 line
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.I don't think we have a way to guarantee the order of
i_sizeand block allocation in f2fs. Seef2fs_write_beginandf2fs_write_end.
Quoted 38 lines
Quoted 3 lines
However,
write_begin&write_endare covered byinode_lock, it could not be racy with inode size check inf2fs_sec_trim_file()as it holdinode_lockas well?Like Daeho said,
write_begin-> checkpoint -> power-cut can give biggeri_blocksthani_size.Quoted 31 lines
Quoted 31 lines
Quoted 29 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 10 lines
fs/f2fs/file.c +2
-1+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) || --2.27.0.383.g050319c2ae-goog
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
..
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 61 lines · Jaegeuk Kim
Quoted 60 lines · Chao Yu
Quoted 58 lines · Jaegeuk Kim
Quoted 50 lines · Chao Yu
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 1 line
Quoted 4 lines
Quoted 1 line
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.I don't think we have a way to guarantee the order of
i_sizeand block allocation in f2fs. Seef2fs_write_beginandf2fs_write_end.
Quoted 6 lines
Quoted 3 lines
However,
write_begin&write_endare covered byinode_lock, it could not be racy with inode size check inf2fs_sec_trim_file()as it holdinode_lockas well?Like Daeho said,
write_begin-> checkpoint -> power-cut can give biggeri_blocksthani_size.
The path won't, cp only persists reserved block in dnode rather than written data block in segment, because data will be copied to page cache after write_begin.
I think truncation path could as Daeho said:
1. truncate -> i_size update however blocks wasn't truncated yet -> checkpoint -> recovery
2. truncate failed -> i_size update however partial blocks was truncated -> fsync
Quoted 34 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.Quoted 2 lines
Quoted 2 lines
.
.
Jaegeuk Kim
maintainerQuoted 66 lines · Chao Yu
Quoted 65 lines · Jaegeuk Kim
Quoted 63 lines · Chao Yu
Quoted 51 lines · Jaegeuk Kim
Quoted 50 lines · Chao Yu
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.I don't think we have a way to guarantee the order of
i_sizeand block allocation in f2fs. Seef2fs_write_beginandf2fs_write_end.However,
write_begin&write_endare covered byinode_lock, it could not be racy with inode size check inf2fs_sec_trim_file()as it holdinode_lockas well?
Quoted 5 lines
Quoted 2 lines
Like Daeho said,
write_begin-> checkpoint -> power-cut can give biggeri_blocksthani_size.The path won't, cp only persists reserved block in dnode rather than written data block in segment, because data will be copied to page cache after
write_begin.
Ah, you're talking about data validity, while I was doing block allocation in this case. In either cases, I'd say secure_trim needs to trim whatever data in valid block *address*.
Quoted 40 lines
I think truncation path could as Daeho said:
1. truncate ->
i_sizeupdate however blocks wasn't truncated yet -> checkpoint -> recovery
2. truncate failed ->i_sizeupdate however partial blocks was truncated -> fsyncQuoted 34 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.Quoted 2 lines
Quoted 2 lines
.
.
Quoted 70 lines · Jaegeuk Kim
Quoted 69 lines · Chao Yu
Quoted 67 lines · Jaegeuk Kim
Quoted 57 lines · Chao Yu
Quoted 56 lines · Jaegeuk Kim
Quoted 54 lines · Chao Yu
Quoted 37 lines · Jaegeuk Kim
Quoted 36 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Changed the way of handling range.len of
F2FS_IOC_SEC_TRIM_FILE.
1. Added -1 value support for range.len to signify the end of file.
2. If the end of the range passes over the end of file, it means until the end of file.
3. ignored the case of that range.len is zero to prevent the function from makingend_addrzero and triggering different behaviour of the function.Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/file.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)fs/f2fs/file.c +3
-4@@ -3813,21 +3813,19 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)file_start_write (filp);inode_lock (inode); -if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode)) { +if (f2fs_is_atomic_file (inode) ||f2fs_compressed_file (inode) || + range.start >= inode->i_size) { ret = -EINVAL ; goto err; } -if (range.start >= inode->i_size) { - ret = -EINVAL ; +if (range.len ==0 ) goto err; - }Quoted 7 lines
fs/f2fs/file.c static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) · line 3826
Quoted 7 lines
fs/f2fs/file.c +2
-5-if (inode->i_size - range.start < range.len) { - ret = -E2BIG ; - goto err; - } - end_addr = range.start + range.len; +if (range.len == (u64)-1 || inode->i_size - range.start < range.len) + end_addr = inode->i_size;We can remove 'range.len == (u64)-1' condition since later condition can cover this?
Quoted 2 lines
Hmm, what if there are blocks beyond
i_size? Do we need to checki_blocksforThe blocks beyond
i_sizewill never be written, there won't be any valid message there, so we don't need to worry about that.Quoted 6 lines
Quoted 2 lines
I don't think we have a way to guarantee the order of
i_sizeand block allocation in f2fs. Seef2fs_write_beginandf2fs_write_end.However,
write_begin&write_endare covered byinode_lock, it could not be racy with inode size check inf2fs_sec_trim_file()as it holdinode_lockas well?Like Daeho said,
write_begin-> checkpoint -> power-cut can give biggeri_blocksthani_size.
Quoted 6 lines
Quoted 2 lines
The path won't, cp only persists reserved block in dnode rather than written data block in segment, because data will be copied to page cache after
write_begin.Ah, you're talking about data validity, while I was doing block allocation in this case. In either cases, I'd say
secure_trimneeds to trim whatever data in valid block *address*.
Yeah, I agreed, sec_trim should trim all data no matter locating inside or beyond isize.
Quoted 43 lines
Quoted 41 lines
I think truncation path could as Daeho said:
1. truncate ->
i_sizeupdate however blocks wasn't truncated yet -> checkpoint -> recovery
2. truncate failed ->i_sizeupdate however partial blocks was truncated -> fsyncQuoted 34 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Thanks,
Quoted 24 lines
ending criteria?
Quoted 14 lines
fs/f2fs/file.c +2
-0+else + end_addr = range.start + range.len; to_end = (end_addr == inode->i_size); if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) ||Signature · 8 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.Quoted 2 lines
Quoted 2 lines
.
.
.