mbox series

[0/2] block: Fix stale page cache of discard or zero out ioctl

Message ID 20211109104723.835533-1-shinichiro.kawasaki@wdc.com (mailing list archive)
Headers show
Series block: Fix stale page cache of discard or zero out ioctl | expand

Message

Shin'ichiro Kawasaki Nov. 9, 2021, 10:47 a.m. UTC
When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
left. This patch series have two fox patches for the stale page cache. Same
fix approach was used as blkdev_fallocate() [1].

[1] https://marc.info/?l=linux-block&m=163236463716836

Shin'ichiro Kawasaki (2):
  block: Hold invalidate_lock in BLKDISCARD ioctl
  block: Hold invalidate_lock in BLKZEROOUT ioctl

 block/ioctl.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

Comments

Ming Lei Nov. 9, 2021, 11:07 a.m. UTC | #1
On Tue, Nov 09, 2021 at 07:47:21PM +0900, Shin'ichiro Kawasaki wrote:
> When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> left. This patch series have two fox patches for the stale page cache. Same
> fix approach was used as blkdev_fallocate() [1].
> 
> [1] https://marc.info/?l=linux-block&m=163236463716836
> 
> Shin'ichiro Kawasaki (2):
>   block: Hold invalidate_lock in BLKDISCARD ioctl
>   block: Hold invalidate_lock in BLKZEROOUT ioctl
> 
>  block/ioctl.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)

Yeah, the discard ioctl needs such fixes too, seems it isn't triggered
in the test disk of my test VM when running block/009.

BTW, BLKRESETZONE may need the fix too.


Thanks,
Ming
Jan Kara Nov. 9, 2021, 11:59 a.m. UTC | #2
On Tue 09-11-21 19:07:26, Ming Lei wrote:
> On Tue, Nov 09, 2021 at 07:47:21PM +0900, Shin'ichiro Kawasaki wrote:
> > When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> > left. This patch series have two fox patches for the stale page cache. Same
> > fix approach was used as blkdev_fallocate() [1].
> > 
> > [1] https://marc.info/?l=linux-block&m=163236463716836
> > 
> > Shin'ichiro Kawasaki (2):
> >   block: Hold invalidate_lock in BLKDISCARD ioctl
> >   block: Hold invalidate_lock in BLKZEROOUT ioctl
> > 
> >  block/ioctl.c | 24 ++++++++++++++++++------
> >  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> Yeah, the discard ioctl needs such fixes too, seems it isn't triggered
> in the test disk of my test VM when running block/009.
> 
> BTW, BLKRESETZONE may need the fix too.

Yeah, it seems like that.

								Honza
Shin'ichiro Kawasaki Nov. 9, 2021, 12:49 p.m. UTC | #3
On Nov 09, 2021 / 12:59, Jan Kara wrote:
> On Tue 09-11-21 19:07:26, Ming Lei wrote:
> > On Tue, Nov 09, 2021 at 07:47:21PM +0900, Shin'ichiro Kawasaki wrote:
> > > When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> > > left. This patch series have two fox patches for the stale page cache. Same
> > > fix approach was used as blkdev_fallocate() [1].
> > > 
> > > [1] https://marc.info/?l=linux-block&m=163236463716836
> > > 
> > > Shin'ichiro Kawasaki (2):
> > >   block: Hold invalidate_lock in BLKDISCARD ioctl
> > >   block: Hold invalidate_lock in BLKZEROOUT ioctl
> > > 
> > >  block/ioctl.c | 24 ++++++++++++++++++------
> > >  1 file changed, 18 insertions(+), 6 deletions(-)
> > 
> > Yeah, the discard ioctl needs such fixes too, seems it isn't triggered
> > in the test disk of my test VM when running block/009.
> > 
> > BTW, BLKRESETZONE may need the fix too.
> 
> Yeah, it seems like that.

Thanks for the comments. I'll work on BLKRESETZONE also.
Jens Axboe Nov. 9, 2021, 2:33 p.m. UTC | #4
On 11/9/21 3:47 AM, Shin'ichiro Kawasaki wrote:
> When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> left. This patch series have two fox patches for the stale page cache. Same
> fix approach was used as blkdev_fallocate() [1].
> 
> [1] https://marc.info/?l=linux-block&m=163236463716836
> 
> Shin'ichiro Kawasaki (2):
>   block: Hold invalidate_lock in BLKDISCARD ioctl
>   block: Hold invalidate_lock in BLKZEROOUT ioctl
> 
>  block/ioctl.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 

Do you want to do a v2 with BLKRESETZONE added as well? I can do these
separately. but a bit awkward right now as my main block 5.16 branch
doesn't yet have the bdev size changes. I'll queue this up post flushing
out the remaining block bits for 5.16, if v2 with BLKRESETZONE happens
before that I'll just use that one.
Jens Axboe Nov. 9, 2021, 5:11 p.m. UTC | #5
On Tue, 9 Nov 2021 19:47:21 +0900, Shin'ichiro Kawasaki wrote:
> When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> left. This patch series have two fox patches for the stale page cache. Same
> fix approach was used as blkdev_fallocate() [1].
> 
> [1] https://marc.info/?l=linux-block&m=163236463716836
> 
> Shin'ichiro Kawasaki (2):
>   block: Hold invalidate_lock in BLKDISCARD ioctl
>   block: Hold invalidate_lock in BLKZEROOUT ioctl
> 
> [...]

Applied, thanks!

[1/2] block: Hold invalidate_lock in BLKDISCARD ioctl
      commit: f275c2aa4b47f3056acd182f2ff752cace21d8a5
[2/2] block: Hold invalidate_lock in BLKZEROOUT ioctl
      commit: 4b4d8b9375582b90f4fd9c708c739593e3a44946

Best regards,
Shin'ichiro Kawasaki Nov. 10, 2021, 1:13 a.m. UTC | #6
On Nov 09, 2021 / 07:33, Jens Axboe wrote:
> On 11/9/21 3:47 AM, Shin'ichiro Kawasaki wrote:
> > When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> > left. This patch series have two fox patches for the stale page cache. Same
> > fix approach was used as blkdev_fallocate() [1].
> > 
> > [1] https://marc.info/?l=linux-block&m=163236463716836
> > 
> > Shin'ichiro Kawasaki (2):
> >   block: Hold invalidate_lock in BLKDISCARD ioctl
> >   block: Hold invalidate_lock in BLKZEROOUT ioctl
> > 
> >  block/ioctl.c | 24 ++++++++++++++++++------
> >  1 file changed, 18 insertions(+), 6 deletions(-)
> > 
> 
> Do you want to do a v2 with BLKRESETZONE added as well? I can do these
> separately. but a bit awkward right now as my main block 5.16 branch
> doesn't yet have the bdev size changes. I'll queue this up post flushing
> out the remaining block bits for 5.16, if v2 with BLKRESETZONE happens
> before that I'll just use that one.

Let's separate the BLKRESETZONE patch. I'll need some more time to prepare it.

I saw the BLKDISCARD and BLKZEROOUT patches queued in the block-5.16 branch.
Thanks!
Chaitanya Kulkarni Nov. 10, 2021, 6:37 a.m. UTC | #7
Shinichiro,

On 11/9/2021 2:47 AM, Shin'ichiro Kawasaki wrote:
> External email: Use caution opening links or attachments
> 
> 
> When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
> left. This patch series have two fox patches for the stale page cache. Same
> fix approach was used as blkdev_fallocate() [1].
> 
> [1] https://marc.info/?l=linux-block&m=163236463716836

Thanks for the fixes, do we have blktest to validate this fix ?
Damien Le Moal Nov. 10, 2021, 6:47 a.m. UTC | #8
On 2021/11/10 15:37, Chaitanya Kulkarni wrote:
> Shinichiro,
> 
> On 11/9/2021 2:47 AM, Shin'ichiro Kawasaki wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> When BLKDISCARD or BLKZEROOUT ioctl race with data read, stale page cache is
>> left. This patch series have two fox patches for the stale page cache. Same
>> fix approach was used as blkdev_fallocate() [1].
>>
>> [1] https://marc.info/?l=linux-block&m=163236463716836
> 
> Thanks for the fixes, do we have blktest to validate this fix ?

Yes. The problem was detected with block/009.