From: Maurizio Lombardi <mlombard@redhat.com>
To: Nitesh Shetty <nj.shetty@samsung.com>
Cc: Jens Axboe <axboe@kernel.dk>, Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
dm-devel@redhat.com, Keith Busch <kbusch@kernel.org>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
James Smart <james.smart@broadcom.com>,
Chaitanya Kulkarni <kch@nvidia.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
James.Bottomley@hansenpartnership.com, bvanassche@acm.org,
hare@suse.de, ming.lei@redhat.com, dlemoal@kernel.org,
anuj20.g@samsung.com, joshi.k@samsung.com,
nitheshshetty@gmail.com, gost.dev@samsung.com,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v11 2/9] block: Add copy offload support infrastructure
Date: Tue, 30 May 2023 13:29:12 +0200 [thread overview]
Message-ID: <CAFL455nMtKbDt1HeN6D2WPB2JjOYq2z1=RagmmuhmQ33eL2Bfw@mail.gmail.com> (raw)
In-Reply-To: <20230522104146.2856-3-nj.shetty@samsung.com>
po 22. 5. 2023 v 13:17 odesílatel Nitesh Shetty <nj.shetty@samsung.com> napsal:
>
> +static int __blkdev_copy_offload(struct block_device *bdev_in, loff_t pos_in,
> + struct block_device *bdev_out, loff_t pos_out, size_t len,
> + cio_iodone_t endio, void *private, gfp_t gfp_mask)
> +{
> + struct cio *cio;
> + struct copy_ctx *ctx;
> + struct bio *read_bio, *write_bio;
> + struct page *token;
> + sector_t copy_len;
> + sector_t rem, max_copy_len;
> +
> + cio = kzalloc(sizeof(struct cio), GFP_KERNEL);
> + if (!cio)
> + return -ENOMEM;
> + atomic_set(&cio->refcount, 0);
> + cio->waiter = current;
> + cio->endio = endio;
> + cio->private = private;
> +
> + max_copy_len = min(bdev_max_copy_sectors(bdev_in),
> + bdev_max_copy_sectors(bdev_out)) << SECTOR_SHIFT;
> +
> + cio->pos_in = pos_in;
> + cio->pos_out = pos_out;
> + /* If there is a error, comp_len will be set to least successfully
> + * completed copied length
> + */
> + cio->comp_len = len;
> + for (rem = len; rem > 0; rem -= copy_len) {
> + copy_len = min(rem, max_copy_len);
> +
> + token = alloc_page(gfp_mask);
> + if (unlikely(!token))
> + goto err_token;
[...]
> +err_token:
> + cio->comp_len = min_t(sector_t, cio->comp_len, (len - rem));
> + if (!atomic_read(&cio->refcount))
> + return -ENOMEM;
> + /* Wait for submitted IOs to complete */
> + return blkdev_copy_wait_completion(cio);
> +}
Suppose the first call to "token = alloc_page()" fails (and
cio->refcount == 0), isn't "cio" going to be leaked here?
Maurizio
next prev parent reply other threads:[~2023-05-30 11:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230522104508epcas5p13f99359d0af12453e0e4bc7f4bae23f0@epcas5p1.samsung.com>
2023-05-22 10:41 ` [PATCH v11 0/9] Implement copy offload support Nitesh Shetty
[not found] ` <CGME20230522104526epcas5p30d6cb07abadb068a95ab1f90dea42d4e@epcas5p3.samsung.com>
2023-05-22 10:41 ` [PATCH v11 1/9] block: Introduce queue limits for copy-offload support Nitesh Shetty
2023-05-22 11:45 ` Damien Le Moal
2023-05-23 7:15 ` Nitesh Shetty
[not found] ` <CGME20230522104536epcas5p23dd8108dd267ec588e5c36e8f9eb9fe8@epcas5p2.samsung.com>
2023-05-22 10:41 ` [PATCH v11 2/9] block: Add copy offload support infrastructure Nitesh Shetty
2023-05-24 15:40 ` [dm-devel] " Darrick J. Wong
2023-05-29 16:36 ` Nitesh Shetty
2023-05-29 17:55 ` Matthew Wilcox
2023-05-30 10:17 ` Nitesh Shetty
2023-05-30 11:29 ` Maurizio Lombardi [this message]
2023-05-30 12:10 ` Nitesh Shetty
[not found] ` <CGME20230522104607epcas5p11b718b8ed5006e92eca0e628b8196f08@epcas5p1.samsung.com>
2023-05-22 10:41 ` [PATCH v11 3/9] block: add emulation for copy Nitesh Shetty
[not found] ` <CGME20230522104617epcas5p25ef0cfacfb4e2d4e8d7a0661f7181e7d@epcas5p2.samsung.com>
2023-05-22 10:41 ` [PATCH v11 4/9] fs, block: copy_file_range for def_blk_ops for direct block device Nitesh Shetty
[not found] ` <CGME20230522104628epcas5p4f5b3f3d7b080950955a127733d554753@epcas5p4.samsung.com>
2023-05-22 10:41 ` [PATCH v11 5/9] nvme: add copy offload support Nitesh Shetty
[not found] ` <CGME20230522104638epcas5p1caf2dc21c5ef7149a10a298b9baeda60@epcas5p1.samsung.com>
2023-05-22 10:41 ` [PATCH v11 6/9] nvmet: add copy command support for bdev and file ns Nitesh Shetty
[not found] ` <CGME20230522104648epcas5p2286a988d89b1befdb49984ebbefb25fd@epcas5p2.samsung.com>
2023-05-22 10:41 ` [PATCH v11 7/9] dm: Add support for copy offload Nitesh Shetty
[not found] ` <CGME20230522104657epcas5p19117017c9dfd3d7a4860d2f9122b1277@epcas5p1.samsung.com>
2023-05-22 10:41 ` [PATCH v11 8/9] dm: Enable copy offload for dm-linear target Nitesh Shetty
[not found] ` <CGME20230522104708epcas5p20f182069898f9c6852826600ce6116c1@epcas5p2.samsung.com>
2023-05-22 10:41 ` [PATCH v11 9/9] null_blk: add support for copy offload Nitesh Shetty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFL455nMtKbDt1HeN6D2WPB2JjOYq2z1=RagmmuhmQ33eL2Bfw@mail.gmail.com' \
--to=mlombard@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=bvanassche@acm.org \
--cc=dlemoal@kernel.org \
--cc=dm-devel@redhat.com \
--cc=gost.dev@samsung.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=joshi.k@samsung.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=nitheshshetty@gmail.com \
--cc=nj.shetty@samsung.com \
--cc=sagi@grimberg.me \
--cc=snitzer@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox