diff mbox series

[2/6] block: remove the NULL bdev check in bdev_read_only

Message ID 20201207131918.2252553-3-hch@lst.de
State Superseded
Headers show
Series [1/6] dm: use bdev_read_only to check if a device is read-only | expand

Commit Message

Christoph Hellwig Dec. 7, 2020, 1:19 p.m. UTC
Only a single caller can end up in bdev_read_only, so move the check there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c | 3 ---
 fs/super.c    | 3 ++-
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Martin K. Petersen Dec. 8, 2020, 5:23 a.m. UTC | #1
Christoph,

> Only a single caller can end up in bdev_read_only, so move the check there.


Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>


-- 
Martin K. Petersen	Oracle Linux Engineering
Ming Lei Dec. 8, 2020, 10:06 a.m. UTC | #2
On Mon, Dec 07, 2020 at 02:19:14PM +0100, Christoph Hellwig wrote:
> Only a single caller can end up in bdev_read_only, so move the check there.

> 

> Signed-off-by: Christoph Hellwig <hch@lst.de>

> ---

>  block/genhd.c | 3 ---

>  fs/super.c    | 3 ++-

>  2 files changed, 2 insertions(+), 4 deletions(-)

> 

> diff --git a/block/genhd.c b/block/genhd.c

> index 09ff6cef028729..c87013879b8650 100644

> --- a/block/genhd.c

> +++ b/block/genhd.c

> @@ -1445,11 +1445,8 @@ EXPORT_SYMBOL(set_disk_ro);

>  

>  int bdev_read_only(struct block_device *bdev)

>  {

> -	if (!bdev)

> -		return 0;

>  	return bdev->bd_read_only;

>  }

> -

>  EXPORT_SYMBOL(bdev_read_only);

>  

>  /*

> diff --git a/fs/super.c b/fs/super.c

> index 2c6cdea2ab2d9e..5a1f384ffc74f6 100644

> --- a/fs/super.c

> +++ b/fs/super.c

> @@ -865,7 +865,8 @@ int reconfigure_super(struct fs_context *fc)

>  

>  	if (fc->sb_flags_mask & SB_RDONLY) {

>  #ifdef CONFIG_BLOCK

> -		if (!(fc->sb_flags & SB_RDONLY) && bdev_read_only(sb->s_bdev))

> +		if (!(fc->sb_flags & SB_RDONLY) && sb->s_bdev &&

> +		    bdev_read_only(sb->s_bdev))

>  			return -EACCES;

>  #endif

>  

> -- 

> 2.29.2

> 


Reviewed-by: Ming Lei <ming.lei@redhat.com>


-- 
Ming
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 09ff6cef028729..c87013879b8650 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1445,11 +1445,8 @@  EXPORT_SYMBOL(set_disk_ro);
 
 int bdev_read_only(struct block_device *bdev)
 {
-	if (!bdev)
-		return 0;
 	return bdev->bd_read_only;
 }
-
 EXPORT_SYMBOL(bdev_read_only);
 
 /*
diff --git a/fs/super.c b/fs/super.c
index 2c6cdea2ab2d9e..5a1f384ffc74f6 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -865,7 +865,8 @@  int reconfigure_super(struct fs_context *fc)
 
 	if (fc->sb_flags_mask & SB_RDONLY) {
 #ifdef CONFIG_BLOCK
-		if (!(fc->sb_flags & SB_RDONLY) && bdev_read_only(sb->s_bdev))
+		if (!(fc->sb_flags & SB_RDONLY) && sb->s_bdev &&
+		    bdev_read_only(sb->s_bdev))
 			return -EACCES;
 #endif