diff mbox series

[RFC,v5,03/10] ovl: implement overlayfs' ->evict_inode operation

Message ID 20210923130814.140814-4-cgxu519@mykernel.net (mailing list archive)
State New, archived
Headers show
Series implement containerized syncfs for overlayfs | expand

Commit Message

Chengguang Xu Sept. 23, 2021, 1:08 p.m. UTC
Implement overlayfs' ->evict_inode operation,
so that we can clear dirty flags of overlayfs inode.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/overlayfs/super.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Miklos Szeredi Oct. 6, 2021, 3:33 p.m. UTC | #1
On Thu, 23 Sept 2021 at 15:08, Chengguang Xu <cgxu519@mykernel.net> wrote:
>
> Implement overlayfs' ->evict_inode operation,
> so that we can clear dirty flags of overlayfs inode.
>
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
> ---
>  fs/overlayfs/super.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> index 51886ba6130a..2ab77adf7256 100644
> --- a/fs/overlayfs/super.c
> +++ b/fs/overlayfs/super.c
> @@ -406,11 +406,18 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data)
>         return ret;
>  }
>
> +static void ovl_evict_inode(struct inode *inode)
> +{
> +       inode->i_state &= ~I_DIRTY_ALL;
> +       clear_inode(inode);

clear_inode() should already clear the dirty flags; the default
eviction should work fine without having to define an ->evict_inode.
What am I missing?

Thanks,
Miklos
Chengguang Xu Oct. 7, 2021, 6:08 a.m. UTC | #2
在 2021/10/6 23:33, Miklos Szeredi 写道:
> On Thu, 23 Sept 2021 at 15:08, Chengguang Xu <cgxu519@mykernel.net> wrote:
>> Implement overlayfs' ->evict_inode operation,
>> so that we can clear dirty flags of overlayfs inode.
>>
>> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
>> ---
>>   fs/overlayfs/super.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
>> index 51886ba6130a..2ab77adf7256 100644
>> --- a/fs/overlayfs/super.c
>> +++ b/fs/overlayfs/super.c
>> @@ -406,11 +406,18 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data)
>>          return ret;
>>   }
>>
>> +static void ovl_evict_inode(struct inode *inode)
>> +{
>> +       inode->i_state &= ~I_DIRTY_ALL;
>> +       clear_inode(inode);
> clear_inode() should already clear the dirty flags; the default
> eviction should work fine without having to define an ->evict_inode.
> What am I missing?

Yeah, you are right, we don't need overlayfs' own ->evict_inode anymore

because we wait all writeback upper inodes in overlayfs' ->sync_fs.


Thanks,

Chengguang
Miklos Szeredi Oct. 7, 2021, 7:43 a.m. UTC | #3
On Thu, 7 Oct 2021 at 08:08, Chengguang Xu <cgxu519@139.com> wrote:
>
> 在 2021/10/6 23:33, Miklos Szeredi 写道:
> > On Thu, 23 Sept 2021 at 15:08, Chengguang Xu <cgxu519@mykernel.net> wrote:
> >> Implement overlayfs' ->evict_inode operation,
> >> so that we can clear dirty flags of overlayfs inode.
> >>
> >> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
> >> ---
> >>   fs/overlayfs/super.c | 7 +++++++
> >>   1 file changed, 7 insertions(+)
> >>
> >> diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
> >> index 51886ba6130a..2ab77adf7256 100644
> >> --- a/fs/overlayfs/super.c
> >> +++ b/fs/overlayfs/super.c
> >> @@ -406,11 +406,18 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data)
> >>          return ret;
> >>   }
> >>
> >> +static void ovl_evict_inode(struct inode *inode)
> >> +{
> >> +       inode->i_state &= ~I_DIRTY_ALL;
> >> +       clear_inode(inode);
> > clear_inode() should already clear the dirty flags; the default
> > eviction should work fine without having to define an ->evict_inode.
> > What am I missing?
>
> Yeah, you are right, we don't need overlayfs' own ->evict_inode anymore
>
> because we wait all writeback upper inodes in overlayfs' ->sync_fs.

Okay, I dropped this patch then.

Thanks,
Miklos
diff mbox series

Patch

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 51886ba6130a..2ab77adf7256 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -406,11 +406,18 @@  static int ovl_remount(struct super_block *sb, int *flags, char *data)
 	return ret;
 }
 
+static void ovl_evict_inode(struct inode *inode)
+{
+	inode->i_state &= ~I_DIRTY_ALL;
+	clear_inode(inode);
+}
+
 static const struct super_operations ovl_super_operations = {
 	.alloc_inode	= ovl_alloc_inode,
 	.free_inode	= ovl_free_inode,
 	.destroy_inode	= ovl_destroy_inode,
 	.drop_inode	= generic_delete_inode,
+	.evict_inode	= ovl_evict_inode,
 	.put_super	= ovl_put_super,
 	.sync_fs	= ovl_sync_fs,
 	.statfs		= ovl_statfs,