From patchwork Wed Oct 5 19:00:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Manzanares X-Patchwork-Id: 9363289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5C046077E for ; Wed, 5 Oct 2016 19:00:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B83F628698 for ; Wed, 5 Oct 2016 19:00:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD1082869E; Wed, 5 Oct 2016 19:00:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7351728698 for ; Wed, 5 Oct 2016 19:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753052AbcJETAZ (ORCPT ); Wed, 5 Oct 2016 15:00:25 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:26293 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752784AbcJETAW (ORCPT ); Wed, 5 Oct 2016 15:00:22 -0400 X-IronPort-AV: E=Sophos;i="5.31,302,1473091200"; d="scan'";a="23884515" Received: from mail-by2nam03lp0056.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([216.32.180.56]) by ob1.hgst.iphmx.com with ESMTP; 06 Oct 2016 03:00:21 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-hgst-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Xl/ly8jw4qeqPtuR6gL68cO79WUpGXDk3/eD8YC8mmU=; b=gDbSxI+DVDifif9/vntYJJxHemnI+0cFfREz6Cx6ilyBFXCHM7reQNWCvscfF/2z+4j/IYTZEYXuCVNMAxb8TSXucvQOkJSsOcj1OWNvOI27MSHi+w7f9b7xOBgiP8dmbspZmIZWg85yd+Pttjf4UpFoFR9c+DcRy1fv2DGZfZw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Adam.Manzanares@hgst.com; Received: from penguito.sanjose.hgst.com (199.255.44.173) by BLUPR0401MB1713.namprd04.prod.outlook.com (10.162.215.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Wed, 5 Oct 2016 19:00:18 +0000 From: Adam Manzanares To: , CC: , , Adam Manzanares Subject: [PATCH v2 2/2] block: Add iocontext priority to request Date: Wed, 5 Oct 2016 12:00:07 -0700 Message-ID: <1475694007-11999-3-git-send-email-adam.manzanares@hgst.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475694007-11999-1-git-send-email-adam.manzanares@hgst.com> References: <1475694007-11999-1-git-send-email-adam.manzanares@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: BY2PR12CA0002.namprd12.prod.outlook.com (10.160.121.12) To BLUPR0401MB1713.namprd04.prod.outlook.com (10.162.215.15) X-MS-Office365-Filtering-Correlation-Id: 9f4bc7c0-9337-4328-9ca3-08d3ed51d9ec X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 2:qOtrAGVSUah6jlfMqn/80/WdF3sKaNEmOielKVK4BqI1KYRPANDq7iTKE+mEvRXhF8nnLNBsDQdCn2AG0UrDji1uNi8OAIfRbltZdJVuoO6i7tVBms1vDWkHAfSp3fJ5QkleP2rJg9a46vhA2vGgmKBfA5EAQjk2bVNnQmjQOkC2sRGVdHbodpvuSTv6X4FmBt7VwOZONIAtwMszAPh3gA==; 3:j062MSef8tOF4IX7FkyHEiuAub5gOF9YvgTNhyw+wkmW0IM2fjDhwry0WtwQnYYYm136wffdTbgHbo/EW6xl7vNIb26+ngk+kHq/QqkpcXi/KBHdQOGI2O87Oergj4TJgQxb2vb8l12/Xg/Mi6gv2w==; 25:6daOyi/+tvdx/edVOgwD+5rl35psRadmDNgiQ+xQWzCYCiQFcdgjkjuQIIGcBxnEznepLN7g9b77n1b1f0hB/sGcA03q8uOZmsu5xaC+WUKuTPynaXQNbQ30KgEwmqiOD2ALTjs7bajLlgK0wbSHmraaAA38FVqjtX/MfCf92wNpJWE900iScGm21hVhOEIqBM9cMZhLOBXKJxIDiTtaD0TyYVWblRk+rI/frXu2n4FoqlOvayUrJVGh0/ZBS9toi4SHnXxm5mg7tVLhHZjv95/sTCdVpfvx6oJxAQwK911GqlitWnsx4T3d+VmXvyx52ovzUW6OojGlCek5aj7No496rHEdTY5GmOQKfl4Fc8EOkaLmqVwB1l1aDhM8By8CBIg7SvJZw3STWnb3L342MDxI6O/9YDUdBeimAiwrP4teEuU+E93tUdsCAOzUyckl X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0401MB1713; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 31:4z115YD/xguD8lbIW2nKz356tlWnw6YpVtqnRtjpm+foF72KqAIGEpsm20LoKDMGrqnTidDrULBZ4NAr4CQkuU4fchhb8s3dpBOq0jplUrLLszNUuxpgPC86sq5d211ZZu+WMUJ0Ep8EDVLvex1po2MKHB0QyM3bEQmqIvAV9j5OnghBFh9acFOjOEViMfUcyuqYp5+X9Uvp6Kk4/ACZ6KM6dsXZazyMjlgKNNCf0Ihjp44HHwKDPbgT16z1bkGv5cVCS74fdbPTLM+3TnKEFA==; 20:OC1LBzQcMnTddDBZmuuOhiFZRSRyHRV9sGgEyZdVQSEXjJHZYq1gTZ7xpxhe/TBif0LRkrkcRZbhuhkrq/LiEwHF/57gEwYHppfzE7Gjykc4zd5az0y/wWwJloX83Yb+ymaNVRdvvu+NuJagTjGDl1B3gYA4yXOqrWHXE1FL4Em1feX+FEB0bJgjerl/pMIwg/nJsY7O+CpPEre+l0MOchiKXwLELIV0He7TaBSe2h8lnu8greg5x7L4GoCQ9e7OqvbdLcCk/OWl5sKRICfXnEGSeMFQw3PuiW7wUudyWL1BRK13hhKu9QXxxC0wPJVXCTDgoDYIhRILoHi6ZQnrIPAU+x6wmdeXkRKZk/i4Cy6Ybo10mkHYwB/IFznpG/p2988L3HwTQCt4j1ztCkisZnFoif9njhJHgH0p33wn6kDmST3NRn6DbAA3pcCAoblXtXAtasg5J/WvdyGgKUKA/238NlJHLHoI087OCRGClv4uUdy56cbcmmRbC0pzA9Ts X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BLUPR0401MB1713; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0401MB1713; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 4:b7LTPAZVHNxYNQTsW76WHohcwgDZA3YDr4C5I5g50oU3B8THSKOYodG0af/rZ5AEGc924W2+sUCMYmFyeTqo2jWfuRpWdRvKEXBXDZXfILepnJVHg5d3iJ0FmjsdNfsxGC3LTyQkbQJdLHZ+wPj49gRdR8KaOjI/7A1tLXC7P1btY+HsXQbX5oQyF99T19WgvT7bNyJ3MfZdO0vpjPXUur96Nm8sQcRLXROiu0Uzqaq1plNYkJHHaa6D/P22YmURFMOYtU3lsQoAsEQQ8Ifs/fKpHeSqKjjHNBiTY/HufwqYfCjGMOA26MTCz1PLa9CoKH5p5HPEsTfj7fYN31pZUurbg5gijODFvppcSpcPSr8sLNrMv15LairaoaJmNJeT+Wq4sCkXa3QfewtZg30sGjg0R5wJ06tGF9z5DtWjsJCrsN66Yj7lOnadJ709z2CgejUPtCQQb7kwuDNeDvQbNg== X-Forefront-PRVS: 008663486A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(68736007)(4001430100002)(77096005)(48376002)(50466002)(6666003)(2950100002)(5003940100001)(5001770100001)(106356001)(305945005)(92566002)(586003)(50226002)(7846002)(7736002)(33646002)(3846002)(6116002)(5660300001)(19580405001)(189998001)(36756003)(66066001)(81166006)(8676002)(19580395003)(81156014)(4326007)(2906002)(97736004)(229853001)(105586002)(47776003)(42186005)(107886002)(101416001)(86362001)(50986999)(76176999)(7099028); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0401MB1713; H:penguito.sanjose.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: hgst.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0401MB1713; 23:cL8VhgKMkKllsDytlP3suiK81V5S9S3XNy1qqk9?= =?us-ascii?Q?HUXQgRDR43quEi1qo1z8IQ/eJO3Xb1d7NMzspLGNS23UueczBPRBD/zFEVZ9?= =?us-ascii?Q?sXjTmgh7/tFhMdRhtvmeQ65YAScAMC1bmDc4vSQJ4loN8UVrose8AqcqXTRm?= =?us-ascii?Q?t1XR+iwdicWFiipNW2KNhCSnI//HyOa6AP3faxm9XTN7MNMsWZuTP0teak85?= =?us-ascii?Q?UpFosmmKnd4cHcpMh6aHOK+6/7zlR61WzXdZ3IEQgfPlAHZgAytqc6D0SMbP?= =?us-ascii?Q?vIm06w/cvyUmk98D0zfb78iFGLThCFaBVcOMY9wgCRQLhBuy0eiKvejXNoAZ?= =?us-ascii?Q?rOi2z+C/RhIAJAI736zsDYAgfQztGvmOPQPUpDG78NSrWdW8HJ61P8RPqbCM?= =?us-ascii?Q?9s2Fcs0jRMvwA/nmpxv2RVz2Z2IXY3PFPToi9HyxvzxU+W88HSrFju+Dn7qr?= =?us-ascii?Q?IUisX1M0aQe85oEETVLzB6WBL5j27PZLrJ3VIqt3wmiGC9NrPohg/XtsfHvT?= =?us-ascii?Q?gyteTRdDJeLBBwQ0jr294l4vqarOEJbRj5M30VLdeNZaELACSQ4SPzmuEaMw?= =?us-ascii?Q?70sNz1hGv9z7WSjypmASuIptn54nTLru/nhO4DzS9XNBW/56W4YZTrF71+a9?= =?us-ascii?Q?amJLRYK75+uNy0rVbxOnPDCvlrTf1n8nc6M4JC5ff2ba+8CU9u8YGuRn9ZQw?= =?us-ascii?Q?GmTIg9vLmacKFnP6WKhzgCRJ9o5lPCgNMfyOwZyWKnDTMt9LjgThjruruETT?= =?us-ascii?Q?uZ6Bfds85rkLv1DuP0H+KGrw+RZLb6kVyLUQJrCm9Pxinr9rBfoaRqaZdd7X?= =?us-ascii?Q?z1Up7WhvsjjYCXuXYK+YNke3Ve10F5NNH9lAhnHEfsmt4h++iVGT/MVKjfy1?= =?us-ascii?Q?bHziPE97e7v7N7oF98ZL0aWUJQnbV57bPtiBTD4zeCnxbmLeceKzJ9hbEXqF?= =?us-ascii?Q?oz17MkNPSWXStqBmHUAko+139ViE25PJuQMKlb5x2YyuPZLcR/cXE/BWc5aR?= =?us-ascii?Q?S249y16LZajGEX6qguBjkrF6OiHwZnJgXB9BSMNY/lwri7DOParuxJ+7mcQ8?= =?us-ascii?Q?w/KGS34ONuJ/4n+2XvsIBcNBIE2x/Z8IFGe5aRocuF7g9coDxhjTij8yw0CX?= =?us-ascii?Q?M5Q3UaRn3GWl2GFsbV03Yiu+JUunno/my?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 6:kbH8kM48FXXbmsSOc2K84Vy9lCVsU57I1uyR2HMd9Id3IZpQ79uupWiecJYTiE6g7NhETKkONwQ6WFMinXzCxwRr8we7GJYyOeNNogthRw0dnXspmC60V70w3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YVPsoM3ZkaR+LtCLbUF3P7hOl+i6yzWtmqWX6GaqVzCaFVJqvz4GBWrOSLCz99BLD4pHhIQ/dRvhN+OYMK3CyTR7PrAtsSZl/Bf/r3UzWPo6Y/I0Q+KYsydLsASJtSNBE8oST X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2016 19:00:18.8663 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0401MB1713 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch adds an association between iocontext ioprio and the ioprio of a request. This feature is only enabled if a queue flag is set to indicate that requests should have ioprio associated with them. The queue flag is exposed as the req_prio queue sysfs entry. Signed-off-by: Adam Mananzanares Reviewed-by: Hannes Reinecke --- block/blk-core.c | 8 +++++++- block/blk-sysfs.c | 32 ++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 36c7ac3..17c3ce5 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -33,6 +33,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -1648,6 +1649,7 @@ out: void init_request_from_bio(struct request *req, struct bio *bio) { + struct io_context *ioc = rq_ioc(bio); req->cmd_type = REQ_TYPE_FS; req->cmd_flags |= bio->bi_opf & REQ_COMMON_MASK; @@ -1656,7 +1658,11 @@ void init_request_from_bio(struct request *req, struct bio *bio) req->errors = 0; req->__sector = bio->bi_iter.bi_sector; - req->ioprio = bio_prio(bio); + if (blk_queue_req_prio(req->q)) + req->ioprio = ioprio_best(bio_prio(bio), ioc->ioprio); + else + req->ioprio = bio_prio(bio); + blk_rq_bio_prep(req->q, req, bio); } diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index f87a7e7..268a71a 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -384,6 +384,31 @@ static ssize_t queue_dax_show(struct request_queue *q, char *page) return queue_var_show(blk_queue_dax(q), page); } +static ssize_t queue_req_prio_show(struct request_queue *q, char *page) +{ + return queue_var_show(blk_queue_req_prio(q), page); +} + +static ssize_t queue_req_prio_store(struct request_queue *q, const char *page, + size_t count) +{ + unsigned long req_prio_on; + ssize_t ret; + + ret = queue_var_store(&req_prio_on, page, count); + if (ret < 0) + return ret; + + spin_lock_irq(q->queue_lock); + if (req_prio_on) + queue_flag_set(QUEUE_FLAG_REQ_PRIO, q); + else + queue_flag_clear(QUEUE_FLAG_REQ_PRIO, q); + spin_unlock_irq(q->queue_lock); + + return ret; +} + static struct queue_sysfs_entry queue_requests_entry = { .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR }, .show = queue_requests_show, @@ -526,6 +551,12 @@ static struct queue_sysfs_entry queue_dax_entry = { .show = queue_dax_show, }; +static struct queue_sysfs_entry queue_req_prio_entry = { + .attr = {.name = "req_prio", .mode = S_IRUGO | S_IWUSR }, + .show = queue_req_prio_show, + .store = queue_req_prio_store, +}; + static struct attribute *default_attrs[] = { &queue_requests_entry.attr, &queue_ra_entry.attr, @@ -553,6 +584,7 @@ static struct attribute *default_attrs[] = { &queue_poll_entry.attr, &queue_wc_entry.attr, &queue_dax_entry.attr, + &queue_req_prio_entry.attr, NULL, }; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index e79055c..23e1e2d 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -505,6 +505,7 @@ struct request_queue { #define QUEUE_FLAG_FUA 24 /* device supports FUA writes */ #define QUEUE_FLAG_FLUSH_NQ 25 /* flush not queueuable */ #define QUEUE_FLAG_DAX 26 /* device supports DAX */ +#define QUEUE_FLAG_REQ_PRIO 27 /* Use iocontext ioprio */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_STACKABLE) | \ @@ -595,6 +596,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) #define blk_queue_secure_erase(q) \ (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags)) #define blk_queue_dax(q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags) +#define blk_queue_req_prio(q) test_bit(QUEUE_FLAG_REQ_PRIO, &(q)->queue_flags) #define blk_noretry_request(rq) \ ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \