* [PATCH v2 0/1] concurrency handling for zoned null-blk [not found] <CGME20200928095910epcas5p2226ab95a8e4fbd3cfe3f48afb1a58c40@epcas5p2.samsung.com> @ 2020-09-28 9:55 ` Kanchan Joshi [not found] ` <CGME20200928095914epcas5p1beae8d5a201c35b598fde8288532d58d@epcas5p1.samsung.com> ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Kanchan Joshi @ 2020-09-28 9:55 UTC (permalink / raw) To: axboe, Damien.LeMoal Cc: linux-kernel, linux-block, stable, selvakuma.s1, nj.shetty, javier.gonz, Kanchan Joshi Changes since v1: - applied the refactoring suggested by Damien Kanchan Joshi (1): null_blk: synchronization fix for zoned device drivers/block/null_blk.h | 1 + drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) -- 2.25.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CGME20200928095914epcas5p1beae8d5a201c35b598fde8288532d58d@epcas5p1.samsung.com>]
* [PATCH v2 1/1] null_blk: synchronization fix for zoned device [not found] ` <CGME20200928095914epcas5p1beae8d5a201c35b598fde8288532d58d@epcas5p1.samsung.com> @ 2020-09-28 9:55 ` Kanchan Joshi 2020-09-28 10:11 ` Damien Le Moal 2020-10-28 2:40 ` Jens Axboe 0 siblings, 2 replies; 7+ messages in thread From: Kanchan Joshi @ 2020-09-28 9:55 UTC (permalink / raw) To: axboe, Damien.LeMoal Cc: linux-kernel, linux-block, stable, selvakuma.s1, nj.shetty, javier.gonz, Kanchan Joshi Parallel write,read,zone-mgmt operations accessing/altering zone state and write-pointer may get into race. Avoid the situation by using a new spinlock for zoned device. Concurrent zone-appends (on a zone) returning same write-pointer issue is also avoided using this lock. Fixes: e0489ed5daeb ("null_blk: Support REQ_OP_ZONE_APPEND") Signed-off-by: Kanchan Joshi <joshi.k@samsung.com> --- drivers/block/null_blk.h | 1 + drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h index daed4a9c3436..28099be50395 100644 --- a/drivers/block/null_blk.h +++ b/drivers/block/null_blk.h @@ -44,6 +44,7 @@ struct nullb_device { unsigned int nr_zones; struct blk_zone *zones; sector_t zone_size_sects; + spinlock_t zone_lock; unsigned long size; /* device size in MB */ unsigned long completion_nsec; /* time in ns to complete a request */ diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c index 3d25c9ad2383..e8d8b13aaa5a 100644 --- a/drivers/block/null_blk_zoned.c +++ b/drivers/block/null_blk_zoned.c @@ -45,6 +45,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) if (!dev->zones) return -ENOMEM; + spin_lock_init(&dev->zone_lock); if (dev->zone_nr_conv >= dev->nr_zones) { dev->zone_nr_conv = dev->nr_zones - 1; pr_info("changed the number of conventional zones to %u", @@ -131,8 +132,11 @@ int null_report_zones(struct gendisk *disk, sector_t sector, * So use a local copy to avoid corruption of the device zone * array. */ + spin_lock_irq(&dev->zone_lock); memcpy(&zone, &dev->zones[first_zone + i], sizeof(struct blk_zone)); + spin_unlock_irq(&dev->zone_lock); + error = cb(&zone, i, data); if (error) return error; @@ -277,18 +281,28 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op, blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd, enum req_opf op, sector_t sector, sector_t nr_sectors) { + blk_status_t sts; + struct nullb_device *dev = cmd->nq->dev; + + spin_lock_irq(&dev->zone_lock); switch (op) { case REQ_OP_WRITE: - return null_zone_write(cmd, sector, nr_sectors, false); + sts = null_zone_write(cmd, sector, nr_sectors, false); + break; case REQ_OP_ZONE_APPEND: - return null_zone_write(cmd, sector, nr_sectors, true); + sts = null_zone_write(cmd, sector, nr_sectors, true); + break; case REQ_OP_ZONE_RESET: case REQ_OP_ZONE_RESET_ALL: case REQ_OP_ZONE_OPEN: case REQ_OP_ZONE_CLOSE: case REQ_OP_ZONE_FINISH: - return null_zone_mgmt(cmd, op, sector); + sts = null_zone_mgmt(cmd, op, sector); + break; default: - return null_process_cmd(cmd, op, sector, nr_sectors); + sts = null_process_cmd(cmd, op, sector, nr_sectors); } + spin_unlock_irq(&dev->zone_lock); + + return sts; } -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/1] null_blk: synchronization fix for zoned device 2020-09-28 9:55 ` [PATCH v2 1/1] null_blk: synchronization fix for zoned device Kanchan Joshi @ 2020-09-28 10:11 ` Damien Le Moal 2020-10-28 2:40 ` Jens Axboe 1 sibling, 0 replies; 7+ messages in thread From: Damien Le Moal @ 2020-09-28 10:11 UTC (permalink / raw) To: Kanchan Joshi, axboe Cc: linux-kernel, linux-block, stable, selvakuma.s1, nj.shetty, javier.gonz On 2020/09/28 18:59, Kanchan Joshi wrote: > Parallel write,read,zone-mgmt operations accessing/altering zone state > and write-pointer may get into race. Avoid the situation by using a new > spinlock for zoned device. > Concurrent zone-appends (on a zone) returning same write-pointer issue > is also avoided using this lock. > > Fixes: e0489ed5daeb ("null_blk: Support REQ_OP_ZONE_APPEND") > Signed-off-by: Kanchan Joshi <joshi.k@samsung.com> > --- > drivers/block/null_blk.h | 1 + > drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- > 2 files changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h > index daed4a9c3436..28099be50395 100644 > --- a/drivers/block/null_blk.h > +++ b/drivers/block/null_blk.h > @@ -44,6 +44,7 @@ struct nullb_device { > unsigned int nr_zones; > struct blk_zone *zones; > sector_t zone_size_sects; > + spinlock_t zone_lock; > > unsigned long size; /* device size in MB */ > unsigned long completion_nsec; /* time in ns to complete a request */ > diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c > index 3d25c9ad2383..e8d8b13aaa5a 100644 > --- a/drivers/block/null_blk_zoned.c > +++ b/drivers/block/null_blk_zoned.c > @@ -45,6 +45,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) > if (!dev->zones) > return -ENOMEM; > > + spin_lock_init(&dev->zone_lock); > if (dev->zone_nr_conv >= dev->nr_zones) { > dev->zone_nr_conv = dev->nr_zones - 1; > pr_info("changed the number of conventional zones to %u", > @@ -131,8 +132,11 @@ int null_report_zones(struct gendisk *disk, sector_t sector, > * So use a local copy to avoid corruption of the device zone > * array. > */ > + spin_lock_irq(&dev->zone_lock); > memcpy(&zone, &dev->zones[first_zone + i], > sizeof(struct blk_zone)); > + spin_unlock_irq(&dev->zone_lock); > + > error = cb(&zone, i, data); > if (error) > return error; > @@ -277,18 +281,28 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op, > blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd, enum req_opf op, > sector_t sector, sector_t nr_sectors) > { > + blk_status_t sts; > + struct nullb_device *dev = cmd->nq->dev; > + > + spin_lock_irq(&dev->zone_lock); > switch (op) { > case REQ_OP_WRITE: > - return null_zone_write(cmd, sector, nr_sectors, false); > + sts = null_zone_write(cmd, sector, nr_sectors, false); > + break; > case REQ_OP_ZONE_APPEND: > - return null_zone_write(cmd, sector, nr_sectors, true); > + sts = null_zone_write(cmd, sector, nr_sectors, true); > + break; > case REQ_OP_ZONE_RESET: > case REQ_OP_ZONE_RESET_ALL: > case REQ_OP_ZONE_OPEN: > case REQ_OP_ZONE_CLOSE: > case REQ_OP_ZONE_FINISH: > - return null_zone_mgmt(cmd, op, sector); > + sts = null_zone_mgmt(cmd, op, sector); > + break; > default: > - return null_process_cmd(cmd, op, sector, nr_sectors); > + sts = null_process_cmd(cmd, op, sector, nr_sectors); > } > + spin_unlock_irq(&dev->zone_lock); > + > + return sts; > } > Looks good. Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/1] null_blk: synchronization fix for zoned device 2020-09-28 9:55 ` [PATCH v2 1/1] null_blk: synchronization fix for zoned device Kanchan Joshi 2020-09-28 10:11 ` Damien Le Moal @ 2020-10-28 2:40 ` Jens Axboe 1 sibling, 0 replies; 7+ messages in thread From: Jens Axboe @ 2020-10-28 2:40 UTC (permalink / raw) To: Kanchan Joshi, Damien.LeMoal Cc: linux-kernel, linux-block, stable, selvakuma.s1, nj.shetty, javier.gonz On 9/28/20 3:55 AM, Kanchan Joshi wrote: > Parallel write,read,zone-mgmt operations accessing/altering zone state > and write-pointer may get into race. Avoid the situation by using a new > spinlock for zoned device. > Concurrent zone-appends (on a zone) returning same write-pointer issue > is also avoided using this lock. Applied, thanks. -- Jens Axboe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/1] concurrency handling for zoned null-blk 2020-09-28 9:55 ` [PATCH v2 0/1] concurrency handling for zoned null-blk Kanchan Joshi [not found] ` <CGME20200928095914epcas5p1beae8d5a201c35b598fde8288532d58d@epcas5p1.samsung.com> @ 2020-09-28 10:08 ` Damien Le Moal 2020-09-28 12:11 ` Greg KH 2 siblings, 0 replies; 7+ messages in thread From: Damien Le Moal @ 2020-09-28 10:08 UTC (permalink / raw) To: Kanchan Joshi, axboe Cc: linux-kernel, linux-block, stable, selvakuma.s1, nj.shetty, javier.gonz On 2020/09/28 18:59, Kanchan Joshi wrote: > Changes since v1: > - applied the refactoring suggested by Damien > > Kanchan Joshi (1): > null_blk: synchronization fix for zoned device > > drivers/block/null_blk.h | 1 + > drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- > 2 files changed, 19 insertions(+), 4 deletions(-) > For single patches, you should add this after the "---" in the patch file, above the patch stats. This is ignores by git when the patch is applied (the patch starts at the first "diff" entry). -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/1] concurrency handling for zoned null-blk 2020-09-28 9:55 ` [PATCH v2 0/1] concurrency handling for zoned null-blk Kanchan Joshi [not found] ` <CGME20200928095914epcas5p1beae8d5a201c35b598fde8288532d58d@epcas5p1.samsung.com> 2020-09-28 10:08 ` [PATCH v2 0/1] concurrency handling for zoned null-blk Damien Le Moal @ 2020-09-28 12:11 ` Greg KH 2020-09-28 17:46 ` Kanchan Joshi 2 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2020-09-28 12:11 UTC (permalink / raw) To: Kanchan Joshi Cc: axboe, Damien.LeMoal, linux-kernel, linux-block, stable, selvakuma.s1, nj.shetty, javier.gonz On Mon, Sep 28, 2020 at 03:25:48PM +0530, Kanchan Joshi wrote: > Changes since v1: > - applied the refactoring suggested by Damien > > Kanchan Joshi (1): > null_blk: synchronization fix for zoned device > > drivers/block/null_blk.h | 1 + > drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- > 2 files changed, 19 insertions(+), 4 deletions(-) > > -- > 2.25.1 > <formletter> This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html for how to do this properly. </formletter> ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/1] concurrency handling for zoned null-blk 2020-09-28 12:11 ` Greg KH @ 2020-09-28 17:46 ` Kanchan Joshi 0 siblings, 0 replies; 7+ messages in thread From: Kanchan Joshi @ 2020-09-28 17:46 UTC (permalink / raw) To: Greg KH Cc: Kanchan Joshi, Jens Axboe, Damien Le Moal, linux-kernel, linux-block, stable, Selvakumar S, Nitesh Shetty, Javier Gonzalez On Mon, Sep 28, 2020 at 5:42 PM Greg KH <gregkh@linuxfoundation.org> wrote: > > On Mon, Sep 28, 2020 at 03:25:48PM +0530, Kanchan Joshi wrote: > > Changes since v1: > > - applied the refactoring suggested by Damien > > > > Kanchan Joshi (1): > > null_blk: synchronization fix for zoned device > > > > drivers/block/null_blk.h | 1 + > > drivers/block/null_blk_zoned.c | 22 ++++++++++++++++++---- > > 2 files changed, 19 insertions(+), 4 deletions(-) > > > > -- > > 2.25.1 > > > > > <formletter> > > This is not the correct way to submit patches for inclusion in the > stable kernel tree. Please read: > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html > for how to do this properly. > > </formletter> I'm sorry for the goof-up, Greg. -- Joshi ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-10-28 23:46 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20200928095910epcas5p2226ab95a8e4fbd3cfe3f48afb1a58c40@epcas5p2.samsung.com> 2020-09-28 9:55 ` [PATCH v2 0/1] concurrency handling for zoned null-blk Kanchan Joshi [not found] ` <CGME20200928095914epcas5p1beae8d5a201c35b598fde8288532d58d@epcas5p1.samsung.com> 2020-09-28 9:55 ` [PATCH v2 1/1] null_blk: synchronization fix for zoned device Kanchan Joshi 2020-09-28 10:11 ` Damien Le Moal 2020-10-28 2:40 ` Jens Axboe 2020-09-28 10:08 ` [PATCH v2 0/1] concurrency handling for zoned null-blk Damien Le Moal 2020-09-28 12:11 ` Greg KH 2020-09-28 17:46 ` Kanchan Joshi
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).