[PATCH v3 2/6] block: Error an attempt to split an atomic write in bio_split()

John Garry posted 6 patches 3 weeks, 3 days ago
There is a newer version of this series
[PATCH v3 2/6] block: Error an attempt to split an atomic write in bio_split()
Posted by John Garry 3 weeks, 3 days ago
This is disallowed.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 block/bio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index 7a93724e4a49..07b971853768 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1749,6 +1749,10 @@ struct bio *bio_split(struct bio *bio, int sectors,
 	if (WARN_ON_ONCE(bio_op(bio) == REQ_OP_ZONE_APPEND))
 		return ERR_PTR(-EINVAL);
 
+	/* atomic writes cannot be split */
+	if (bio->bi_opf & REQ_ATOMIC)
+		return ERR_PTR(-EINVAL);
+
 	split = bio_alloc_clone(bio->bi_bdev, bio, gfp, bs);
 	if (!split)
 		return ERR_PTR(-ENOMEM);
-- 
2.31.1
Re: [PATCH v3 2/6] block: Error an attempt to split an atomic write in bio_split()
Posted by Hannes Reinecke 2 weeks, 5 days ago
On 10/31/24 10:59, John Garry wrote:
> This is disallowed.
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>   block/bio.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/block/bio.c b/block/bio.c
> index 7a93724e4a49..07b971853768 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -1749,6 +1749,10 @@ struct bio *bio_split(struct bio *bio, int sectors,
>   	if (WARN_ON_ONCE(bio_op(bio) == REQ_OP_ZONE_APPEND))
>   		return ERR_PTR(-EINVAL);
>   
> +	/* atomic writes cannot be split */
> +	if (bio->bi_opf & REQ_ATOMIC)
> +		return ERR_PTR(-EINVAL);
> +
>   	split = bio_alloc_clone(bio->bi_bdev, bio, gfp, bs);
>   	if (!split)
>   		return ERR_PTR(-ENOMEM);

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich