From: James Bottomley <James.Bottomley@suse.de>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
linux-scsi <linux-scsi@vger.kernel.org>,
dm-devel@redhat.com
Subject: [RFC 2/2] sd: free discard page in unprep function
Date: Wed, 30 Jun 2010 12:10:53 -0500 [thread overview]
Message-ID: <1277917853.2839.174.camel@mulgrave.site> (raw)
In-Reply-To: <1277917264.2839.153.camel@mulgrave.site>
This isn't a proper patch, but really just an illustration how freeing
should be done ... it still needs to be paired correctly with the
allocation (and error handling on the allocation path).
James
---
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8802e48..7907be8 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -461,6 +461,12 @@ static int sd_prepare_discard(struct request *rq)
return BLKPREP_OK;
}
+static void sd_unprep_fn(struct request_queue *q, struct request *rq)
+{
+ if (rq->cmd_flags & REQ_DISCARD)
+ __free_page(bio_page(rq->bio));
+}
+
/**
* sd_init_command - build a scsi (read or write) command from
* information in the request structure.
@@ -2226,6 +2232,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
sd_revalidate_disk(gd);
blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
+ blk_queue_unprep_rq(sdp->request_queue, sd_unprep_fn);
gd->driverfs_dev = &sdp->sdev_gendev;
gd->flags = GENHD_FL_EXT_DEVT;
next prev parent reply other threads:[~2010-06-30 17:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-30 17:01 [RFC 1/2] block: implement an unprep function corresponding directly to prep James Bottomley
2010-06-30 17:10 ` James Bottomley [this message]
2010-06-30 17:23 ` Mike Snitzer
2010-06-30 17:51 ` Jens Axboe
2010-06-30 17:54 ` Martin K. Petersen
2010-07-01 1:47 ` FUJITA Tomonori
2010-07-01 3:47 ` Mike Snitzer
2010-07-01 4:44 ` [dm-devel] " FUJITA Tomonori
2010-07-02 11:03 ` Christoph Hellwig
2010-07-05 7:00 ` FUJITA Tomonori
2010-07-05 19:24 ` Christoph Hellwig
2010-07-05 21:50 ` Mark Lord
2010-07-05 21:54 ` Mark Lord
2010-07-05 22:00 ` Jeff Garzik
2010-08-03 3:01 ` Mark Lord
2010-07-06 7:04 ` FUJITA Tomonori
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=1277917853.2839.174.camel@mulgrave.site \
--to=james.bottomley@suse.de \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=snitzer@redhat.com \
/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