From: "Jan Beulich" Subject: Re: [PATCH] xen-blkback: convert hole punching to discard request on loop devices Date: Tue, 08 Nov 2011 16:01:31 +0000 Message-ID: <4EB9606B020000780005FA5B@nat28.tlf.novell.com> References: <1320654866-12457-1-git-send-email-lidongyang@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1320654866-12457-1-git-send-email-lidongyang@novell.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Dong Yang Li Cc: lczerner@redhat.com, xen-devel@lists.xensource.com, konrad.wilk@oracle.com List-Id: xen-devel@lists.xenproject.org >>> On 07.11.11 at 09:34, Li Dongyang wrote: > As of dfaa2ef68e80c378e610e3c8c536f1c239e8d3ef, loop devices support > discard request now. We could just issue a discard request, and > the loop driver will punch the hole for us, so we don't need to touch > the internals of loop device and punch the hole ourselves, Thanks. Looking at what the loop driver now does - doesn't the original code here lack support for lo_offset being non-zero then? If so, should we fix this in pre-3.2 kernels? Jan > Signed-off-by: Li Dongyang > --- > drivers/block/xen-blkback/blkback.c | 21 +++------------------ > 1 files changed, 3 insertions(+), 18 deletions(-) >=20 > diff --git a/drivers/block/xen-blkback/blkback.c=20 > b/drivers/block/xen-blkback/blkback.c > index 15ec4db..ad365a7 100644 > --- a/drivers/block/xen-blkback/blkback.c > +++ b/drivers/block/xen-blkback/blkback.c > @@ -39,9 +39,6 @@ > #include > #include > #include > -#include > -#include > -#include > =20 > #include > #include > @@ -422,25 +419,13 @@ static void xen_blk_discard(struct xen_blkif = *blkif,=20 > struct blkif_request *req) > int status =3D BLKIF_RSP_OKAY; > struct block_device *bdev =3D blkif->vbd.bdev; > =20 > - if (blkif->blk_backend_type =3D=3D BLKIF_BACKEND_PHY) > - /* just forward the discard request */ > + if (blkif->blk_backend_type =3D=3D BLKIF_BACKEND_PHY || > + blkif->blk_backend_type =3D=3D BLKIF_BACKEND_FILE) > err =3D blkdev_issue_discard(bdev, > req->u.discard.sector_number, > req->u.discard.nr_sectors, > GFP_KERNEL, 0); > - else if (blkif->blk_backend_type =3D=3D BLKIF_BACKEND_FILE) { > - /* punch a hole in the backing file */ > - struct loop_device *lo =3D bdev->bd_disk->private_data; > - struct file *file =3D lo->lo_backing_file; > - > - if (file->f_op->fallocate) > - err =3D file->f_op->fallocate(file, > - FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE,= > - req->u.discard.sector_number << 9, > - req->u.discard.nr_sectors << 9); > - else > - err =3D -EOPNOTSUPP; > - } else > + else > err =3D -EOPNOTSUPP; > =20 > if (err =3D=3D -EOPNOTSUPP) {