Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1956495AbdDZHhq (ORCPT ); Wed, 26 Apr 2017 03:37:46 -0400 Received: from smtp.ctxuk.citrix.com ([185.25.65.24]:8051 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1036116AbdDZHhh (ORCPT ); Wed, 26 Apr 2017 03:37:37 -0400 X-IronPort-AV: E=Sophos;i="5.37,253,1488844800"; d="scan'208";a="44953817" Date: Wed, 26 Apr 2017 08:37:20 +0100 From: Roger Pau =?iso-8859-1?Q?Monn=E9?= To: Logan Gunthorpe CC: , , , , , , , , , , , , , , , , , Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Jens Axboe , Greg Kroah-Hartman , Dan Williams , Ross Zwisler , Matthew Wilcox , Sumit Semwal , Stephen Bates , Boris Ostrovsky , Juergen Gross , Konrad Rzeszutek Wilk , Julien Grall Subject: Re: [PATCH v2 15/21] xen-blkfront: Make use of the new sg_map helper function Message-ID: <20170426073720.okv33ly2ldepilti@dhcp-3-128.uk.xensource.com> References: <1493144468-22493-1-git-send-email-logang@deltatee.com> <1493144468-22493-16-git-send-email-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1493144468-22493-16-git-send-email-logang@deltatee.com> User-Agent: NeoMutt/20170306 (1.8.0) X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2832 Lines: 73 On Tue, Apr 25, 2017 at 12:21:02PM -0600, Logan Gunthorpe wrote: > Straightforward conversion to the new helper, except due to the lack > of error path, we have to use SG_MAP_MUST_NOT_FAIL which may BUG_ON in > certain cases in the future. > > Signed-off-by: Logan Gunthorpe > Cc: Boris Ostrovsky > Cc: Juergen Gross > Cc: Konrad Rzeszutek Wilk > Cc: "Roger Pau Monn?" > --- > drivers/block/xen-blkfront.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c > index 3945963..ed62175 100644 > --- a/drivers/block/xen-blkfront.c > +++ b/drivers/block/xen-blkfront.c > @@ -816,8 +816,9 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri > BUG_ON(sg->offset + sg->length > PAGE_SIZE); > > if (setup.need_copy) { > - setup.bvec_off = sg->offset; > - setup.bvec_data = kmap_atomic(sg_page(sg)); > + setup.bvec_off = 0; > + setup.bvec_data = sg_map(sg, 0, SG_KMAP_ATOMIC | > + SG_MAP_MUST_NOT_FAIL); I assume that sg_map already adds sg->offset to the address? Also wondering whether we can get rid of bvec_off and just increment bvec_data, adding Julien who IIRC added this code. > } > > gnttab_foreach_grant_in_range(sg_page(sg), > @@ -827,7 +828,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri > &setup); > > if (setup.need_copy) > - kunmap_atomic(setup.bvec_data); > + sg_unmap(sg, setup.bvec_data, 0, SG_KMAP_ATOMIC); > } > if (setup.segments) > kunmap_atomic(setup.segments); > @@ -1053,7 +1054,7 @@ static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset) > case XEN_SCSI_DISK5_MAJOR: > case XEN_SCSI_DISK6_MAJOR: > case XEN_SCSI_DISK7_MAJOR: > - *offset = (*minor / PARTS_PER_DISK) + > + *offset = (*minor / PARTS_PER_DISK) + > ((major - XEN_SCSI_DISK1_MAJOR + 1) * 16) + > EMULATED_SD_DISK_NAME_OFFSET; > *minor = *minor + > @@ -1068,7 +1069,7 @@ static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset) > case XEN_SCSI_DISK13_MAJOR: > case XEN_SCSI_DISK14_MAJOR: > case XEN_SCSI_DISK15_MAJOR: > - *offset = (*minor / PARTS_PER_DISK) + > + *offset = (*minor / PARTS_PER_DISK) + > ((major - XEN_SCSI_DISK8_MAJOR + 8) * 16) + > EMULATED_SD_DISK_NAME_OFFSET; > *minor = *minor + > @@ -1119,7 +1120,7 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, > if (!VDEV_IS_EXTENDED(info->vdevice)) { > err = xen_translate_vdev(info->vdevice, &minor, &offset); > if (err) > - return err; > + return err; Cosmetic changes should go in a separate patch please. Roger.