Re: [RFC PATCH v3 1/2] block: add simple copy support
From: Johannes Thumshirn <hidden>
Date: 2020-12-11 17:32:14
Also in:
dm-devel, linux-nvme, linux-scsi, lkml
From: Johannes Thumshirn <hidden>
Date: 2020-12-11 17:32:14
Also in:
dm-devel, linux-nvme, linux-scsi, lkml
On 11/12/2020 15:57, SelvaKumar S wrote: [...]
+int blk_copy_emulate(struct block_device *bdev, struct blk_copy_payload *payload,
+ gfp_t gfp_mask)
+{
+ struct request_queue *q = bdev_get_queue(bdev);
+ struct bio *bio;
+ void *buf = NULL;
+ int i, nr_srcs, max_range_len, ret, cur_dest, cur_size;
+
+ nr_srcs = payload->copy_range;
+ max_range_len = q->limits.max_copy_range_sectors << SECTOR_SHIFT;
+ cur_dest = payload->dest;
+ buf = kvmalloc(max_range_len, GFP_ATOMIC);Why GFP_ATOMIC and not the passed in gfp_mask? Especially as this is a kvmalloc() which has the potential to grow quite big.
+int __blkdev_issue_copy(struct block_device *bdev, sector_t dest,
+ sector_t nr_srcs, struct range_entry *rlist, gfp_t gfp_mask,
+ int flags, struct bio **biop)
+{[...]
+ total_size = struct_size(payload, range, nr_srcs); + payload = kmalloc(total_size, GFP_ATOMIC | __GFP_NOWARN);
Same here.
diff --git a/block/ioctl.c b/block/ioctl.c index 6b785181344f..a4a507d85e56 100644 --- a/block/ioctl.c +++ b/block/ioctl.c@@ -142,6 +142,47 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode, GFP_KERNEL, flags); } +static int blk_ioctl_copy(struct block_device *bdev, fmode_t mode, + unsigned long arg, unsigned long flags) +{
[...]
+ + rlist = kmalloc_array(crange.nr_range, sizeof(*rlist), + GFP_ATOMIC | __GFP_NOWARN);
And here. I think this one can even be GFP_KERNEL.