f2fs: report readonly status in ->fsync
PATCH 3/5 f2fs: report readonly status in ->fsync
Report readonly status of filesystem during fsync.
--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
@@ -197,7 +197,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) };if (unlikely (f2fs_readonly (inode->i_sb))) -return 0 ; +return -EROFS ;trace_f2fs_sync_file_enter (inode);
Signature · 1 line
2.6.3
Quoted 1 line · Chao Yu
Report readonly status of filesystem during fsync.
If this means that fsync returns EROFS when used on a file on a read-only filesystem., then this looks buggy - EROFS is not documented for fsync (only as "fd is bound to a special file which does not support synchronization") for this condition, and I don't think other filesystems do that (just tried xfs).
It also doesn't quite make sense - fsync should only fail when the file couldn't be synced, but in most (probably all) cases, the file is already synchronised, otherwise the filesystem shouldn't be RO.
I only looked at the diff, so if I missed the context and my reasoning doesn't apply, forgive and ignore me :)
Signature · 8 lines
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / [email protected]
-=====/_/_//_/\_,_/ /_/\_\
------------------------------------------------------------------------------Quoted 7 lines
-----Original Message-----
From: Marc Lehmann [mailto:[email protected]]
Sent: Saturday, December 26, 2015 2:33 PM
To: Chao Yu
Cc: [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/5] f2fs: report readonly status in ->fsync
Quoted 8 lines
Quoted 1 line · Chao Yu
Report readonly status of filesystem during fsync.
If this means that fsync returns EROFS when used on a file on a read-only filesystem., then this looks buggy - EROFS is not documented for fsync (only as "fd is bound to a special file which does not support synchronization") for this condition, and I don't think other filesystems do that (just tried xfs).
Yes.
Quoted 4 lines
It also doesn't quite make sense - fsync should only fail when the file couldn't be synced, but in most (probably all) cases, the file is already synchronised, otherwise the filesystem shouldn't be RO.
Agreed,
One situation here is if '.' or '..' in dentry page of directory inode was missing (corrupted directory), once fsck found this kind of inode exist in the image, it will mark inode with F2FS_INLINE_DOTS flag, after that f2fs will try to recover it to normal one if user touch such inode in ->lookup, so the dirty data was generated even in a readonly fs.
Actually even for above case, it would be better to avoid generating dirty data rather than stop user fsync in a readonly fs.
Hi Jaegeuk, could you help to drop this patch?
And one more thing is how do you think of moving inline dot recovery into fsck?
Thanks,
Quoted 11 lines
I only looked at the diff, so if I missed the context and my reasoning doesn't apply, forgive and ignore me :)
--
The choice of a Deliantra, the free code+content MORPG -----==- _GNU_ http://www.deliantra.net ----==-- _ generation ---==---(_)__ __ ____ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=====/_/_//_/\_,_/ /_/\_\
------------------------------------------------------------------------------
Jaegeuk Kim
maintainerHi Chao,
Thanks Marc for your report.
Quoted 31 lines · Chao Yu
Quoted 7 lines
-----Original Message-----
From: Marc Lehmann [mailto:[email protected]]
Sent: Saturday, December 26, 2015 2:33 PM
To: Chao Yu
Cc: [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/5] f2fs: report readonly status in ->fsyncQuoted 8 lines
Quoted 1 line · Chao Yu
Report readonly status of filesystem during fsync.
If this means that fsync returns EROFS when used on a file on a read-only filesystem., then this looks buggy - EROFS is not documented for fsync (only as "fd is bound to a special file which does not support synchronization") for this condition, and I don't think other filesystems do that (just tried xfs).
Yes.
Quoted 4 lines
It also doesn't quite make sense - fsync should only fail when the file couldn't be synced, but in most (probably all) cases, the file is already synchronised, otherwise the filesystem shouldn't be RO.
Agreed,
One situation here is if '.' or '..' in dentry page of directory inode was missing (corrupted directory), once fsck found this kind of inode exist in the image, it will mark inode with
F2FS_INLINE_DOTSflag, after that f2fs will try to recover it to normal one if user touch such inode in ->lookup, so the dirty data was generated even in a readonly fs.
Quoted 4 lines
Actually even for above case, it would be better to avoid generating dirty data rather than stop user fsync in a readonly fs.
Hi Jaegeuk, could you help to drop this patch?
Okay.
Quoted 3 lines
And one more thing is how do you think of moving inline dot recovery into fsck?
Hmm, we can't move that part entirely into fsck regarding to backward compatibility. We can add that in fsck, but it needs another block allocation part which we need to handle -ENOSPC in fsck as well.
Thanks,
Quoted 14 lines
Thanks,
Quoted 11 lines
I only looked at the diff, so if I missed the context and my reasoning doesn't apply, forgive and ignore me :)
--
The choice of a Deliantra, the free code+content MORPG -----==- _GNU_ http://www.deliantra.net ----==-- _ generation ---==---(_)__ __ ____ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=====/_/_//_/\_,_/ /_/\_\
------------------------------------------------------------------------------
Hi Jaegeuk,
Quoted 48 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, December 29, 2015 6:44 AM
To: Chao Yu
Cc: 'Marc Lehmann'; [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/5] f2fs: report readonly status in ->fsyncHi Chao,
Thanks Marc for your report.
Quoted 31 lines · Chao Yu
Quoted 7 lines
-----Original Message-----
From: Marc Lehmann [mailto:[email protected]]
Sent: Saturday, December 26, 2015 2:33 PM
To: Chao Yu
Cc: [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/5] f2fs: report readonly status in ->fsyncQuoted 8 lines
Quoted 1 line · Chao Yu
Report readonly status of filesystem during fsync.
If this means that fsync returns EROFS when used on a file on a read-only filesystem., then this looks buggy - EROFS is not documented for fsync (only as "fd is bound to a special file which does not support synchronization") for this condition, and I don't think other filesystems do that (just tried xfs).
Yes.
Quoted 4 lines
It also doesn't quite make sense - fsync should only fail when the file couldn't be synced, but in most (probably all) cases, the file is already synchronised, otherwise the filesystem shouldn't be RO.
Agreed,
One situation here is if '.' or '..' in dentry page of directory inode was missing (corrupted directory), once fsck found this kind of inode exist in the image, it will mark inode with
F2FS_INLINE_DOTSflag, after that f2fs will try to recover it to normal one if user touch such inode in ->lookup, so the dirty data was generated even in a readonly fs.Quoted 4 lines
Actually even for above case, it would be better to avoid generating dirty data rather than stop user fsync in a readonly fs.
Hi Jaegeuk, could you help to drop this patch?
Quoted 8 lines
Okay.
Quoted 3 lines
And one more thing is how do you think of moving inline dot recovery into fsck?
Hmm, we can't move that part entirely into fsck regarding to backward compatibility.
IMO, dynamical repair could be optional, not a must. Because when touching such incomplete directory in ->lookup, we could leave some dmesg to remind user to repair. Or if user found this issue by himself, also he could repair it by using fsck. So this shouldn't case a backward compatibility issue, or am I missing something?
Quoted 2 lines
We can add that in fsck, but it needs another block allocation part which we need to handle
-ENOSPCin fsck as well.
That's right, is it possible to do defragment (gc) if there is no more space when allocating block?
Thanks,
Quoted 17 lines
Thanks,
Quoted 14 lines
Thanks,
Quoted 11 lines
I only looked at the diff, so if I missed the context and my reasoning doesn't apply, forgive and ignore me :)
--
The choice of a Deliantra, the free code+content MORPG -----==- _GNU_ http://www.deliantra.net ----==-- _ generation ---==---(_)__ __ ____ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=====/_/_//_/\_,_/ /_/\_\
------------------------------------------------------------------------------
Jaegeuk Kim
maintainerHi Chao,
...
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
And one more thing is how do you think of moving inline dot recovery into fsck?
Hmm, we can't move that part entirely into fsck regarding to backward compatibility.
IMO, dynamical repair could be optional, not a must. Because when touching such incomplete directory in ->lookup, we could leave some dmesg to remind user to repair. Or if user found this issue by himself, also he could repair it by using fsck. So this shouldn't case a backward compatibility issue, or am I missing something?
Hmm, it seems that maybe I misunderstood your *moving it into fsck*. Anyway, I'm fine to add kernel messages as well.
And, in any case, the only way to fix this case is to run fsck at first. One approach, as I implemented, is to set a flag and then repair it at runtime.
The other one is to repair by fsck, as you suggested.
In this case, my concern is that current fsck is working without allocating blocks, since it is a little bit risky right now.
For example, if there is no valid user block, not free space, fsck should handle ENOSPC while changing the existing disk, which has not been fully validated so far.
Ah, otherwise, we can activate inline_dentry by fsck for this special case, once inline_dentry in f2fs becomes pretty much stable later. :)
Thanks,
Quoted 26 lines
Quoted 3 lines
We can add that in fsck, but it needs another block allocation part which we need to handle
-ENOSPCin fsck as well.That's right, is it possible to do defragment (gc) if there is no more space when allocating block?
Thanks,
Quoted 17 lines
Thanks,
Quoted 14 lines
Thanks,
Quoted 11 lines
I only looked at the diff, so if I missed the context and my reasoning doesn't apply, forgive and ignore me :)
--
The choice of a Deliantra, the free code+content MORPG -----==- _GNU_ http://www.deliantra.net ----==-- _ generation ---==---(_)__ __ ____ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=====/_/_//_/\_,_/ /_/\_\
------------------------------------------------------------------------------
Hi Jaegeuk,
Quoted 17 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, December 30, 2015 8:33 AM
To: Chao Yu
Cc: 'Marc Lehmann'; [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/5] f2fs: report readonly status in ->fsyncHi Chao,
...
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
And one more thing is how do you think of moving inline dot recovery into fsck?
Hmm, we can't move that part entirely into fsck regarding to backward compatibility.
Quoted 7 lines
Quoted 5 lines
IMO, dynamical repair could be optional, not a must. Because when touching such incomplete directory in ->lookup, we could leave some dmesg to remind user to repair. Or if user found this issue by himself, also he could repair it by using fsck. So this shouldn't case a backward compatibility issue, or am I missing something?
Hmm, it seems that maybe I misunderstood your *moving it into fsck*.
What I mean is 1) enable repair ability in fsck, 2) keep repair in kernel side optionally. For compatibility, we leave dmesg for user when touch this kind of dir if we choose to disable repair in kernel.
Quoted 1 line
Anyway, I'm fine to add kernel messages as well.
OK, will do it in ("f2fs: fix to stop recovering dot dentries in a readonly fs")
Quoted 9 lines
And, in any case, the only way to fix this case is to run fsck at first. One approach, as I implemented, is to set a flag and then repair it at runtime.
The other one is to repair by fsck, as you suggested.
In this case, my concern is that current fsck is working without allocating blocks, since it is a little bit risky right now.
For example, if there is no valid user block, not free space, fsck should handle ENOSPC while changing the existing disk, which has not been fully validated so far.
That' right.
Quoted 3 lines
Ah, otherwise, we can activate
inline_dentryby fsck for this special case, onceinline_dentryin f2fs becomes pretty much stable later. :)
Or we can active inline_data for file which has i_size less than MAX_INLINE_SIZE.
That will be cool to use inline_dentry by default! :)
Thanks,
Quoted 29 lines
Thanks,
Quoted 26 lines
Quoted 3 lines
We can add that in fsck, but it needs another block allocation part which we need to handle
-ENOSPCin fsck as well.That's right, is it possible to do defragment (gc) if there is no more space when allocating block?
Thanks,
Quoted 17 lines
Thanks,
Quoted 14 lines
Thanks,
Quoted 11 lines
I only looked at the diff, so if I missed the context and my reasoning doesn't apply, forgive and ignore me :)
--
The choice of a Deliantra, the free code+content MORPG -----==- _GNU_ http://www.deliantra.net ----==-- _ generation ---==---(_)__ __ ____ __ Marc Lehmann --==---/ / _ \/ // /\ \/ / [email protected] -=====/_/_//_/\_,_/ /_/\_\
------------------------------------------------------------------------------