public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] f2fs: support zero sized file truncate for device aliasing files
@ 2025-03-21 21:33 Daeho Jeong
  2025-03-24 16:28 ` Jaegeuk Kim
  2025-03-25  2:19 ` [f2fs-dev] " Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Daeho Jeong @ 2025-03-21 21:33 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

support a file truncation to zero size for device aliasing files.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
v2: make the extent length zero
---
 fs/f2fs/file.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f92a9fba9991..69952f208086 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -775,6 +775,11 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
 		f2fs_update_time(sbi, REQ_TIME);
 
 		f2fs_put_page(ipage, 1);
+
+		write_lock(&et->lock);
+		et->largest.len = 0;
+		write_unlock(&et->lock);
+
 		goto out;
 	}
 
@@ -1036,7 +1041,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 
 	if ((attr->ia_valid & ATTR_SIZE)) {
 		if (!f2fs_is_compress_backend_ready(inode) ||
-				IS_DEVICE_ALIASING(inode))
+				(IS_DEVICE_ALIASING(inode) && attr->ia_size))
 			return -EOPNOTSUPP;
 		if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) &&
 			!IS_ALIGNED(attr->ia_size,
-- 
2.49.0.395.g12beb8f557-goog


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

* Re: [PATCH v2] f2fs: support zero sized file truncate for device aliasing files
  2025-03-21 21:33 [PATCH v2] f2fs: support zero sized file truncate for device aliasing files Daeho Jeong
@ 2025-03-24 16:28 ` Jaegeuk Kim
  2025-03-24 16:56   ` Daeho Jeong
  2025-03-25  2:19 ` [f2fs-dev] " Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2025-03-24 16:28 UTC (permalink / raw)
  To: Daeho Jeong; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, Daeho Jeong

Do we still need this patch?

On 03/21, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> support a file truncation to zero size for device aliasing files.
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> v2: make the extent length zero
> ---
>  fs/f2fs/file.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index f92a9fba9991..69952f208086 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -775,6 +775,11 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
>  		f2fs_update_time(sbi, REQ_TIME);
>  
>  		f2fs_put_page(ipage, 1);
> +
> +		write_lock(&et->lock);
> +		et->largest.len = 0;
> +		write_unlock(&et->lock);
> +
>  		goto out;
>  	}
>  
> @@ -1036,7 +1041,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  
>  	if ((attr->ia_valid & ATTR_SIZE)) {
>  		if (!f2fs_is_compress_backend_ready(inode) ||
> -				IS_DEVICE_ALIASING(inode))
> +				(IS_DEVICE_ALIASING(inode) && attr->ia_size))
>  			return -EOPNOTSUPP;
>  		if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) &&
>  			!IS_ALIGNED(attr->ia_size,
> -- 
> 2.49.0.395.g12beb8f557-goog
> 

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

* Re: [PATCH v2] f2fs: support zero sized file truncate for device aliasing files
  2025-03-24 16:28 ` Jaegeuk Kim
@ 2025-03-24 16:56   ` Daeho Jeong
  0 siblings, 0 replies; 4+ messages in thread
From: Daeho Jeong @ 2025-03-24 16:56 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, Daeho Jeong

On Mon, Mar 24, 2025 at 9:28 AM Jaegeuk Kim <jaegeuk@kernel.org> wrote:
>
> Do we still need this patch?

Yes, in many circumstances, we cannot remove the aliasing file because
of SELinux.

>
> On 03/21, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> >
> > support a file truncation to zero size for device aliasing files.
> >
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > ---
> > v2: make the extent length zero
> > ---
> >  fs/f2fs/file.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index f92a9fba9991..69952f208086 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -775,6 +775,11 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
> >               f2fs_update_time(sbi, REQ_TIME);
> >
> >               f2fs_put_page(ipage, 1);
> > +
> > +             write_lock(&et->lock);
> > +             et->largest.len = 0;
> > +             write_unlock(&et->lock);
> > +
> >               goto out;
> >       }
> >
> > @@ -1036,7 +1041,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> >
> >       if ((attr->ia_valid & ATTR_SIZE)) {
> >               if (!f2fs_is_compress_backend_ready(inode) ||
> > -                             IS_DEVICE_ALIASING(inode))
> > +                             (IS_DEVICE_ALIASING(inode) && attr->ia_size))
> >                       return -EOPNOTSUPP;
> >               if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) &&
> >                       !IS_ALIGNED(attr->ia_size,
> > --
> > 2.49.0.395.g12beb8f557-goog
> >

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

* Re: [f2fs-dev] [PATCH v2] f2fs: support zero sized file truncate for device aliasing files
  2025-03-21 21:33 [PATCH v2] f2fs: support zero sized file truncate for device aliasing files Daeho Jeong
  2025-03-24 16:28 ` Jaegeuk Kim
@ 2025-03-25  2:19 ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2025-03-25  2:19 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team
  Cc: chao, Daeho Jeong

On 3/22/25 05:33, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> support a file truncation to zero size for device aliasing files.
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> v2: make the extent length zero
> ---
>  fs/f2fs/file.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index f92a9fba9991..69952f208086 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -775,6 +775,11 @@ int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
>  		f2fs_update_time(sbi, REQ_TIME);
>  
>  		f2fs_put_page(ipage, 1);
> +
> +		write_lock(&et->lock);
> +		et->largest.len = 0;
> +		write_unlock(&et->lock);

f2fs_mark_inode_dirty_sync(inode, true); ?

Thanks,

> +
>  		goto out;
>  	}
>  
> @@ -1036,7 +1041,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
>  
>  	if ((attr->ia_valid & ATTR_SIZE)) {
>  		if (!f2fs_is_compress_backend_ready(inode) ||
> -				IS_DEVICE_ALIASING(inode))
> +				(IS_DEVICE_ALIASING(inode) && attr->ia_size))
>  			return -EOPNOTSUPP;
>  		if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED) &&
>  			!IS_ALIGNED(attr->ia_size,


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

end of thread, other threads:[~2025-03-25  2:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 21:33 [PATCH v2] f2fs: support zero sized file truncate for device aliasing files Daeho Jeong
2025-03-24 16:28 ` Jaegeuk Kim
2025-03-24 16:56   ` Daeho Jeong
2025-03-25  2:19 ` [f2fs-dev] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox