[f2fs-dev] [PATCH v2] f2fs: fix to set noatime and immutable flag for quota file

2023-05-25 Thread Chao Yu
We should set noatime bit for quota files, since no one cares about atime of quota file, and we should set immutalbe bit as well, due to nobody should write to the file through exported interfaces. Meanwhile this patch use inode_lock to avoid race condition during inode->i_flags, f2fs_inode->i_fla

Re: [f2fs-dev] [PATCH 09/11] fs: factor out a direct_write_fallback helper

2023-05-25 Thread Christoph Hellwig
On Wed, May 24, 2023 at 09:00:36AM +0200, Miklos Szeredi wrote: > > +ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter, > > + ssize_t direct_written, ssize_t buffered_written) > > +{ > > + struct address_space *mapping = iocb->ki_filp->f_mapping; > > +

Re: [f2fs-dev] [PATCH 10/11] fuse: update ki_pos in fuse_perform_write

2023-05-25 Thread Christoph Hellwig
On Wed, May 24, 2023 at 09:07:22AM +0200, Miklos Szeredi wrote: > > - endbyte = pos + written_buffered - 1; > > + endbyte = iocb->ki_pos + written_buffered - 1; > > Wrong endpos. > > > > > - err = filemap_write_and_wait_range(file->f_mapping, pos, > > +

[f2fs-dev] [PATCH 5/6] fs: Lock moved directories

2023-05-25 Thread Jan Kara
When a directory is moved to a different directory, some filesystems (udf, ext4, ocfs2, f2fs, and likely gfs2, reiserfs, and others) need to update their pointer to the parent and this must not race with other operations on the directory. Lock the directories when they are moved. Although not all f

[f2fs-dev] [PATCH 1/6] ext4: Remove ext4 locking of moved directory

2023-05-25 Thread Jan Kara
Remove locking of moved directory in ext4_rename2(). We will take care of it in VFS instead. This effectively reverts commit 0813299c586b ("ext4: Fix possible corruption when moving a directory") and followup fixes. CC: Ted Tso CC: sta...@vger.kernel.org Signed-off-by: Jan Kara --- fs/ext4/name

[f2fs-dev] [PATCH 3/6] Revert "f2fs: fix potential corruption when moving a directory"

2023-05-25 Thread Jan Kara
This reverts commit d94772154e524b329a168678836745d2773a6e02. The locking is going to be provided by VFS. CC: Jaegeuk Kim CC: sta...@vger.kernel.org Signed-off-by: Jan Kara --- fs/f2fs/namei.c | 16 +--- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/fs/f2fs/namei.c b

[f2fs-dev] [PATCH 2/6] Revert "udf: Protect rename against modification of moved directory"

2023-05-25 Thread Jan Kara
This reverts commit f950fd0529130a617b3da526da9fb6a896ce87c2. The locking is going to be provided by vfs_rename() in the following patches. CC: sta...@vger.kernel.org Signed-off-by: Jan Kara --- fs/udf/namei.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/fs

[f2fs-dev] [PATCH 4/6] fs: Establish locking order for unrelated directories

2023-05-25 Thread Jan Kara
Currently the locking order of inode locks for directories that are not in ancestor relationship is not defined because all operations that needed to lock two directories like this were serialized by sb->s_vfs_rename_mutex. However some filesystems need to lock two subdirectories for RENAME_EXCHANG

[f2fs-dev] [PATCH 6/6] fs: Restrict lock_two_nondirectories() to non-directory inodes

2023-05-25 Thread Jan Kara
Currently lock_two_nondirectories() is skipping any passed directories. After vfs_rename() uses lock_two_inodes(), all the remaining four users of this function pass only regular files to it. So drop the somewhat unusual "skip directory" logic and instead warn if anybody passes directory to it. Thi

[f2fs-dev] [PATCH 0/6] fs: Fix directory corruption when moving directories

2023-05-25 Thread Jan Kara
Hello, this patch set fixes a problem with cross directory renames originally reported in [1]. To quickly sum it up some filesystems (so far we know at least about ext4, udf, f2fs, ocfs2, likely also reiserfs, gfs2 and others) need to lock the directory when it is being renamed into another direct

Re: [f2fs-dev] [PATCH 07/11] iomap: update ki_pos in iomap_file_buffered_write

2023-05-25 Thread Andreas Gruenbacher
On Wed, May 24, 2023 at 8:54 AM Christoph Hellwig wrote: > All callers of iomap_file_buffered_write need to updated ki_pos, move it > into common code. Thanks for this set of cleanups, especially for the patch killing current->backing_dev_info. Reviewed-by: Andreas Gruenbacher > Signed-off-by:

Re: [f2fs-dev] [PATCH v8] fsck.f2fs: Detect and fix looped node chain efficiently

2023-05-25 Thread Jaegeuk Kim
On 05/24, Chunhai Guo wrote: > find_fsync_inode() detect the looped node chain by comparing the loop > counter with free blocks. While it may take tens of seconds to quit when > the free blocks are large enough. We can use Floyd's cycle detection > algorithm to make the detection more efficient, an

[f2fs-dev] [PATCH v2 4/4] mkfs.f2fs: refactor format flow for cleanup

2023-05-25 Thread Chao Yu
During formatting device, node/data block and filesystem metatdata related to same inode were updated in separated functions, e.g. for root inode: - f2fs_write_root_inode() updates root inode's block - f2fs_write_check_point_pack updates its nat/sit journal, summary block Result in: - there are so

Re: [f2fs-dev] [PATCH 3/4] mkfs.f2fs: cleanup w/ alloc_next_free_block()

2023-05-25 Thread Chao Yu
On 2023/5/24 9:40, Jaegeuk Kim wrote: On 05/18, Chao Yu wrote: On 2023/5/18 9:36, Jaegeuk Kim wrote: On 05/17, Chao Yu wrote: Introduce alloc_next_free_block() to wrap below openned codes: blkaddr = get_sb(main_blkaddr) + c.cur_seg[curseg_type] * c.blks_per_seg

Re: [f2fs-dev] [PATCH] f2fs: Detect and fix looped node chain efficiently

2023-05-25 Thread Chao Yu
On 2023/5/24 16:33, Chunhai Guo wrote: find_fsync_dnodes() detect the looped node chain by comparing the loop counter with free blocks. While it may take tens of seconds to quit when the free blocks are large enough. We can use Floyd's cycle detection algorithm to make the detection more efficien

[f2fs-dev] [PATCH 1/2] f2fs-tools: fix to le32 type variable correctly

2023-05-25 Thread Chao Yu
Fix below incorrect use: - compare cpu and le32 type variable: if (get_sb(feature) & cpu_to_le32(F2FS_FEATURE_RO)) - compare le32 type vairable: if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) - miss get_sb(feature) (cpu_to_le32(F2FS_FEATURE_RO) ? 1 : 0) - update le32 type variable sb->featur

[f2fs-dev] [PATCH 2/2] f2fs-tools: reuse feature_table in print_sb_state()

2023-05-25 Thread Chao Yu
Signed-off-by: Chao Yu --- fsck/mount.c | 56 +-- include/f2fs_fs.h | 42 +-- 2 files changed, 41 insertions(+), 57 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index 70e8b46..60ad493 100644 --- a/fsck/moun

[f2fs-dev] [PATCH v2 2/2] f2fs-tools: reuse feature_table to clean up print_sb_state()

2023-05-25 Thread Chao Yu
reuse feature_table in print_sb_state() for cleanup. Signed-off-by: Chao Yu --- v2: - add commit message. fsck/mount.c | 56 +-- include/f2fs_fs.h | 42 +-- 2 files changed, 41 insertions(+), 57 deletions(-) diff -