linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bdev: reset first_open when looping in __blkget_dev
@ 2019-12-17 18:04 Michal Suchanek
  2019-12-18 12:27 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Suchanek @ 2019-12-17 18:04 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel; +Cc: Alexander Viro, Michal Suchanek

It is not clear that no other thread cannot open the block device when
__blkget_dev drops it and loop to restart label. Reset first_open to
false when looping.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 fs/block_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 69bf2fb6f7cd..17e1231d5246 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1560,7 +1560,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 	int ret;
 	int partno;
 	int perm = 0;
-	bool first_open = false;
+	bool first_open;
 
 	if (mode & FMODE_READ)
 		perm |= MAY_READ;
@@ -1580,6 +1580,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
  restart:
 
 	ret = -ENXIO;
+	first_open = false;
 	disk = bdev_get_gendisk(bdev, &partno);
 	if (!disk)
 		goto out;
-- 
2.23.0


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

* Re: [PATCH] bdev: reset first_open when looping in __blkget_dev
  2019-12-17 18:04 [PATCH] bdev: reset first_open when looping in __blkget_dev Michal Suchanek
@ 2019-12-18 12:27 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-12-18 12:27 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

On Tue 17-12-19 19:04:28, Michal Suchanek wrote:
> It is not clear that no other thread cannot open the block device when
> __blkget_dev drops it and loop to restart label. Reset first_open to
> false when looping.
> 
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>

Yeah, good catch. Thanks for the patch. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/block_dev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 69bf2fb6f7cd..17e1231d5246 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1560,7 +1560,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
>  	int ret;
>  	int partno;
>  	int perm = 0;
> -	bool first_open = false;
> +	bool first_open;
>  
>  	if (mode & FMODE_READ)
>  		perm |= MAY_READ;
> @@ -1580,6 +1580,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
>   restart:
>  
>  	ret = -ENXIO;
> +	first_open = false;
>  	disk = bdev_get_gendisk(bdev, &partno);
>  	if (!disk)
>  		goto out;
> -- 
> 2.23.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2019-12-18 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 18:04 [PATCH] bdev: reset first_open when looping in __blkget_dev Michal Suchanek
2019-12-18 12:27 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).