lkml.org 
[lkml]   [2011]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: RFC : mmc: mmc_blk_issue_secdiscard_rq() and mmc_blk_issue_discard_rq() effectively merged into one.
From
Hi,

On Wed, Aug 24, 2011 at 2:09 PM, NamJae Jeon <linkinjeon@gmail.com> wrote:
> Hi.
>
> I am wordering why mmc_blk_issue_secdiscard_rq() and
> mmc_blk_issue_discard_rq() is seperated.
> So I try to make mmc_blk_issue_secdiscard_rq() and
> mmc_blk_issue_discard_rq() effectively merged into one.
>
> I want to know your opinion.

I think not special reason. It can merge one function. but note that
secdiscard function is rarely called. there's only one path from
BLKSECDISCARD ioctl.

however discard is different. it's called relatively frequently if you
turn on discard mount option. or often when batched discard.
So it's helpful to reduce the code size if one function is used. it's
more helpful to optimize the code flow when discard is used.

Thank you,
Kyungmin Park
>
> Thanks.
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
> static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
> {
>        struct mmc_blk_data *md = mq->data;
>        struct mmc_card *card = md->queue.card;
>        unsigned int from, nr, arg;
>        int err = 0;
>        from = blk_rq_pos(req);
>        nr = blk_rq_sectors(req);
>        if (req->cmd_flags & REQ_SECURE) {
>                if (!mmc_can_secure_erase_trim(card)) {
>                        err = -EOPNOTSUPP;
>                        goto out;
>                }
>                if(mmc_can_trim(card) &&
> !mmc_erase_group_aligned(card, from, nr))
>                        arg = MMC_SECURE_TRIM1_ARG;
>                else
>                        arg = MMC_SECURE_ERASE_ARG;
>        }
>        else {
>                if (!mmc_can_erase(card)) {
>                        err = -EOPNOTSUPP;
>                        goto out;
>                }
>                if (mmc_can_trim(card))
>                        arg = MMC_TRIM_ARG;
>                else
>                        arg = MMC_ERASE_ARG;
>        }
>
>        if (card->quirks & MMC_QUIRK_INAND_CMD38) {
>                if(req->cmd_flags & REQ_SECURE)
>                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>                                        NAND_CMD38_ARG_EXT_CSD,
>                                        arg == MMC_SECURE_TRIM1_ARG ?
>                                        INAND_CMD38_ARG_SECTRIM1 :
>                                        INAND_CMD38_ARG_SECERASE,
>                                        0);
>                else
>                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>                                        INAND_CMD38_ARG_EXT_CSD,
>                                        arg == MMC_TRIM_ARG ?
>                                        INAND_CMD38_ARG_TRIM :
>                                        INAND_CMD38_ARG_ERASE,
>                                        0);
>                if (err)
>                        goto out;
>        }
>        err = mmc_erase(card, from, nr, arg);
>        if (!err && arg == MMC_SECURE_TRIM1_ARG) {
>                if (card->quirks & MMC_QUIRK_INAND_CMD38) {
>                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>                                         INAND_CMD38_ARG_EXT_CSD,
>                                         INAND_CMD38_ARG_SECTRIM2,
>                                         0);
>                        if (err)
>                                goto out;
>                }
>                err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
>        }
> out:
>        spin_lock_irq(&md->lock);
>        __blk_end_request(req, err, blk_rq_bytes(req));
>        spin_unlock_irq(&md->lock);
>        return err ? 0 : 1;
> }
>
>
> static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
> {
>        int ret;
>        struct mmc_blk_data *md = mq->data;
>        struct mmc_card *card = md->queue.card;
>        mmc_claim_host(card->host);
>        ret = mmc_blk_part_switch(card, md);
>        if (ret) {
>                ret = 0;
>                goto out;
>        }
>        if (req->cmd_flags & REQ_DISCARD) {
>                ret = mmc_blk_issue_discard_rq(mq, req);
>        } else if (req->cmd_flags & REQ_FLUSH) {
>                ret = mmc_blk_issue_flush(mq, req);
>        } else {
>                ret = mmc_blk_issue_rw_rq(mq, req);
>        }
> out:
>        mmc_release_host(card->host);
>        return ret;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-08-24 07:55    [W:0.042 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site