From patchwork Mon Dec 10 12:50:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 1010402 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="naC2v1xy"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43D2zw2flMz9s3C for ; Mon, 10 Dec 2018 23:53:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbeLJMw6 (ORCPT ); Mon, 10 Dec 2018 07:52:58 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:23631 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeLJMw6 (ORCPT ); Mon, 10 Dec 2018 07:52:58 -0500 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20181210125253epoutp0479774b851c24683d9d64f6af39fef642~u_cs07tqD2137621376epoutp04A; Mon, 10 Dec 2018 12:52:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20181210125253epoutp0479774b851c24683d9d64f6af39fef642~u_cs07tqD2137621376epoutp04A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1544446373; bh=ZZcKUIF8IjEvnUVynzOp/q6rYaHlb5tclTwykLFlvXU=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=naC2v1xy94+GLpDgPC/QxKZCYTxFrNzWSa3VvvKGgzWxaBSytS/sWWwYc43VbWAZv 4e1m/vZW9FvlY7rtRwdxJjhEntfoCYBErIReSzXSJzvUhVaFloeJBkrJrpZXGiPcSK R67vjtSYUyJq5jg13mi5RdfsPHYj6fOYcMCPCNQA= Received: from epsmges1p2.samsung.com (unknown [182.195.42.54]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20181210125252epcas1p2685b9b6ab26afb6f5501b33c14f4a941~u_crwYEZF2636526365epcas1p2w; Mon, 10 Dec 2018 12:52:52 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 5C.4C.04057.4A16E0C5; Mon, 10 Dec 2018 21:52:52 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20181210125251epcas1p3023db72cc08d6b2f899141d551d53f61~u_cqvnT7y3032130321epcas1p3V; Mon, 10 Dec 2018 12:52:51 +0000 (GMT) X-AuditID: b6c32a36-d19ff70000000fd9-71-5c0e61a46cad Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 35.23.03601.2A16E0C5; Mon, 10 Dec 2018 21:52:51 +0900 (KST) Received: from test-PowerEdge-R720.sa.corp.samsungelectronics.net ([107.108.221.212]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PJI00DVHUFKZF90@mmp1.samsung.com>; Mon, 10 Dec 2018 21:52:50 +0900 (KST) From: Kanchan Joshi To: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, viro@zeniv.linux.org.uk, darrick.wong@oracle.com, axboe@kernel.dk, jrdr.linux@gmail.com, ebiggers@google.com, jooyoung.hwang@samsung.com, chur.lee@samsung.com, prakash.v@samsung.com, Kanchan Joshi Subject: [PATCH 1/2] fs: introduce APIs to enable sending write-hint with buffer-head Date: Mon, 10 Dec 2018 18:20:03 +0530 Message-id: <1544446204-5291-2-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1544446204-5291-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzVRa0hTURzv7D52t5q7bWInNalBHzRcGmo3yIoKuoSW+CVIKYe7qel07TpN wVpitUx6kCRKzqWFoJFrLtvMEKfzQaWufOM0bSKYFpLWDMTcbn37PQ8//odAJNNoIJGRncto shVZMlyItnSGysOfKfySI8r6CGp1RY9Sja77OLU8P4NTrh9vMMrZWIJR8/V1gLqx8hRQjo0l nBoZ1iFUpWESp9re9aHUUHktQt0sW+NTA+s92DE/uqQ5n7ZVufi00aylP3/U0sUfHAi9PDeB 0vcsDYBusgyj9E9zCG12L/EShOeFh5VMVkYeo9l/JEWYvujeQNX1kquzXXZMBwziUiAgIBkF 79pa0VIgJCSkFcBBWyfOkd8AdqwNbxLCl5prjeT0twB6Xph4HKngwS8TVl8IJ0Ph4COt91V/ Mha6Tb8wbwYhDTw4sOzgeQ0peQ4uWYpRL0bJvbDGMIp5uyLyOOw1hXOLQuB4/x3EiwXkCai7 qfcNguRXHFqcLj4XOgkbe4wYh6VwocfC54YGwU+OWE5m4Z9JB8J19QCO6ipRzjgKnW3rvj0I 6Qe/r5ZhXFcE9bckXISGz196/l3lMYATTe34A7DTCLY0gABGzarSGDZSfUDOKlSsNjtNnpqj MgPft4fFWEFtf5wdkASQbRMlFIuSJZgijy1Q2QEkEJm/KPzSpiRSKgoKGU3ORY02i2HtIIhA ZTtE7sDqJAmZpshlMhlGzWj+uzxCEKgDfH28KXWu+uCFsPya/MTbwSa3cmzt29bM3R3E1Dgm DrZZ+p7URR3iTycv6mbiL6d0wYen9pR0F8HtswFT2sSRHPHYtbP8jqHu6N4z6hBP5S5jklQu tCoX/KRVnph15744pvn1FYH4elEhcGiCqttbnG3R5af5loho/H3FK0yGsumKyDBEwyr+AmMT dZjyAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsVy+t9jAd3FiXwxBle+M1t8/dLBYrH6bj+b xcfnD9ks7r7fzmpxcXULq8Xz5YsZLRq/LGS0OPr/LZvFtasNzBYz591hs9iz9ySLxZUpi5gt Wnt+sluc/3uc1YHPo2VzucfOWXfZPRZsKvW4fLbUo+nMUWaPj09vsXj0bVnF6LF+y1UWj8+b 5Dw2PXnLFMAVxWWTkpqTWZZapG+XwJXx5sl/loLlQhWPjhxibWCcx9/FyMEhIWAi8XSXYRcj F4eQwE5GibUPfrNBODOZJB5/PMwEUsQmoClxYXJpFyMnh4iArcSTDd9YQWqYBeYxSRy7u4gd JCEsEC7xdksTC4jNIqAqMX/edVaQXl4BJ4kTG3RBwhICchI3z3Uyg9icAs4SDa0dbCC2EFDJ tK0t7BMYeRYwMqxilEwtKM5Nzy02KjDMSy3XK07MLS7NS9dLzs/dxAgM2m2Htfp2MN5fEn+I UYCDUYmHN6CJN0aINbGsuDL3EKMEB7OSCK9uGlCINyWxsiq1KD++qDQntfgQozQHi5I47+28 Y5FCAumJJanZqakFqUUwWSYOTqkGxtzOWV3+xw6p7NgX+uzN9fMOFzbO3rHkAdOGE30qd+vC KwXk1KVLv9+d+tRJ9rSfDdd2c0Zl5fN65h+3KhYyeGh/f2SySDWiK3TtFn+HAIOUydksuYxX 03rv2dXfPawgvl7d5/9eU6c79p6TnhcvnDN5ecwZoYAj7UtOd51P6tThvnj2ff6k+UosxRmJ hlrMRcWJACnMTmxWAgAA X-CMS-MailID: 20181210125251epcas1p3023db72cc08d6b2f899141d551d53f61 X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20181210125251epcas1p3023db72cc08d6b2f899141d551d53f61 References: <1544446204-5291-1-git-send-email-joshi.k@samsung.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org submit_bh and write_dirty_buffer do not take write-hint as parameter. This patch introduces variants which do. Signed-off-by: Kanchan Joshi --- fs/buffer.c | 21 +++++++++++++++++++++ include/linux/buffer_head.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/fs/buffer.c b/fs/buffer.c index 1286c2b..60c8867 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3094,6 +3094,13 @@ int submit_bh(int op, int op_flags, struct buffer_head *bh) } EXPORT_SYMBOL(submit_bh); +int submit_bh_write_hint(int op, int op_flags, struct buffer_head *bh, + enum rw_hint hint) +{ + return submit_bh_wbc(op, op_flags, bh, hint, NULL); +} +EXPORT_SYMBOL(submit_bh_write_hint); + /** * ll_rw_block: low-level access to block devices (DEPRECATED) * @op: whether to %READ or %WRITE @@ -3162,6 +3169,20 @@ void write_dirty_buffer(struct buffer_head *bh, int op_flags) } EXPORT_SYMBOL(write_dirty_buffer); +void write_dirty_buffer_write_hint(struct buffer_head *bh, int op_flags, + enum rw_hint hint) +{ + lock_buffer(bh); + if (!test_clear_buffer_dirty(bh)) { + unlock_buffer(bh); + return; + } + bh->b_end_io = end_buffer_write_sync; + get_bh(bh); + submit_bh_wbc(REQ_OP_WRITE, op_flags, bh, hint, NULL); +} +EXPORT_SYMBOL(write_dirty_buffer_write_hint); + /* * For a data-integrity writeout, we need to wait upon any in-progress I/O * and then start new I/O and then wait upon it. The caller must have a ref on diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 7b73ef7..ac9f111 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -200,7 +200,10 @@ void ll_rw_block(int, int, int, struct buffer_head * bh[]); int sync_dirty_buffer(struct buffer_head *bh); int __sync_dirty_buffer(struct buffer_head *bh, int op_flags); void write_dirty_buffer(struct buffer_head *bh, int op_flags); +void write_dirty_buffer_write_hint(struct buffer_head *bh, int op_flags, + enum rw_hint hint); int submit_bh(int, int, struct buffer_head *); +int submit_bh_write_hint(int, int, struct buffer_head *, enum rw_hint hint); void write_boundary_block(struct block_device *bdev, sector_t bblock, unsigned blocksize); int bh_uptodate_or_lock(struct buffer_head *bh); From patchwork Mon Dec 10 12:50:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 1010403 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="j7aVNb5t"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43D2zy73Qfz9s8F for ; Mon, 10 Dec 2018 23:53:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727351AbeLJMxB (ORCPT ); Mon, 10 Dec 2018 07:53:01 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:48472 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727207AbeLJMxB (ORCPT ); Mon, 10 Dec 2018 07:53:01 -0500 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20181210125257epoutp035973a3c7827d34291e022028f0d470ba~u_cwe4DpU0044300443epoutp03W; Mon, 10 Dec 2018 12:52:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20181210125257epoutp035973a3c7827d34291e022028f0d470ba~u_cwe4DpU0044300443epoutp03W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1544446377; bh=6owZdA1HYY7Sq1NqGAZbq9zQGKfdwV28v9sSi6Md/c4=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=j7aVNb5tJtkpA55KzRe6w2ujbmKdp6/gq3ZUsDeJStZ6k5At7tAW9nSrx2ij+kdg4 QuFAUCReYZhg4fgP6iCbhK062I7N6RfTCxQrSVgKtyOYE+TkXX48Ozn5sUcn2kJ30y vp/0kkC04FF/FCf1s1oWZuZbLcTQLT45a4mRjIgw= Received: from epsmges1p2.samsung.com (unknown [182.195.42.54]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20181210125256epcas1p3ae41b40fafbebea66af19f1fdfde0398~u_cwI6qZK1921319213epcas1p35; Mon, 10 Dec 2018 12:52:56 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 6D.4C.04057.8A16E0C5; Mon, 10 Dec 2018 21:52:56 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20181210125256epcas1p1e4142cfefb9b21dfb8dad927fbd49143~u_cvsN8i52672026720epcas1p1H; Mon, 10 Dec 2018 12:52:56 +0000 (GMT) X-AuditID: b6c32a36-d31ff70000000fd9-76-5c0e61a87365 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 26.23.03601.8A16E0C5; Mon, 10 Dec 2018 21:52:56 +0900 (KST) Received: from test-PowerEdge-R720.sa.corp.samsungelectronics.net ([107.108.221.212]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PJI00DVHUFKZF90@mmp1.samsung.com>; Mon, 10 Dec 2018 21:52:56 +0900 (KST) From: Kanchan Joshi To: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, viro@zeniv.linux.org.uk, darrick.wong@oracle.com, axboe@kernel.dk, jrdr.linux@gmail.com, ebiggers@google.com, jooyoung.hwang@samsung.com, chur.lee@samsung.com, prakash.v@samsung.com, Kanchan Joshi Subject: [PATCH 2/2] fs/ext4,jbd2: Add support for passing write-hint with journal. Date: Mon, 10 Dec 2018 18:20:04 +0530 Message-id: <1544446204-5291-3-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1544446204-5291-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsWy7bCmru6KRL4Yg5UXzCy+fulgsVh9t5/N 4uPzh2wWd99vZ7W4uLqF1eL58sWMFo1fFjJaHP3/ls3i2tUGZouZ8+6wWezZe5LF4sqURcwW rT0/2S3O/z3O6sDn0bK53GPnrLvsHgs2lXpcPlvq0XTmKLPHx6e3WDz6tqxi9Fi/5SqLx+dN ch6bnrxlCuCK4rJJSc3JLEst0rdL4MrY+PUla8Er54oDn6axNjD2WHQxcnJICJhIrJ7Zzt7F yMUhJLCDUeL2zO1MEM53Rokbb2cxwlSdX/ISqmo3o8SDxk2MEM50Jol9d7tYuxg5ONgENCUu TC4FaRARsJV4suEbK0gNs8A8JonzH48ygSSEBUIl7jw5yg5iswioShw4eBZsA6+Ak8Sl5sPs ENvkJG6e62QGsTkFnCUaWjvYQAZJCDxmk3j7fjsbRJGLxLz/v5ghbGGJV8e3sIMcISEgLXHp qC1EuFji152jzBC9HYwS1xtmskAk7CUu7vkLdhCzAJ/Eu689rBC9vBIdbUIQJR4SS+48Z4V4 chqjxKtlExknMEouYGRYxSiWWlCcm55abFhgpFecmFtcmpeul5yfu4kRHPFaZjsYF53zOcQo wMGoxMMb0MQbI8SaWFZcmXuIUYKDWUmEVzcNKMSbklhZlVqUH19UmpNafIhRmoNFSZz3idTc aCGB9MSS1OzU1ILUIpgsEwenVANjzsflIY/sM44YWf65WJ12vNUq6eCu9bfUXHfcZjKbcuiM 4J3WzTkL5kfOj2K202CtCqspcJxl2hs0b9ORQ3dnGsufYrti6cT0aNPjnXd5fx5K4Xthcajn DScnn+mRk1vv2+4VOeUXtjp6ydGfrEGzmYp3bbzUect6zxmxOazHbdpOCYRcvPypWomlOCPR UIu5qDgRAP9gWar0AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsVy+t9jAd0ViXwxBhNXiFl8/dLBYrH6bj+b xcfnD9ks7r7fzmpxcXULq8Xz5YsZLRq/LGS0OPr/LZvFtasNzBYz591hs9iz9ySLxZUpi5gt Wnt+sluc/3uc1YHPo2VzucfOWXfZPRZsKvW4fLbUo+nMUWaPj09vsXj0bVnF6LF+y1UWj8+b 5Dw2PXnLFMAVxWWTkpqTWZZapG+XwJWx8etL1oJXzhUHPk1jbWDssehi5OSQEDCROL/kJXsX IxeHkMBORok7B09COTOZJM4d2A/kcHCwCWhKXJhcCtIgImAr8WTDN1aQGmaBeUwSx+4uYgdJ CAuEStx5chTMZhFQlThw8CwjiM0r4CRxqfkwO8Q2OYmb5zqZQWxOAWeJhtYONhBbCKhm2tYW 9gmMPAsYGVYxSqYWFOem5xYbFRjmpZbrFSfmFpfmpesl5+duYgQG7rbDWn07GO8viT/EKMDB qMTDG9DEGyPEmlhWXJl7iFGCg1lJhFc3DSjEm5JYWZValB9fVJqTWnyIUZqDRUmc93besUgh gfTEktTs1NSC1CKYLBMHp1QDo4XH82v8QTJmx1f6n19zK1Fi9qIK/22Xa/kcr7HPkZnS/6TM 2in1wUaWtwpL1W9u+9G07WXe7Dnbv3yYPuWSw4ok5zvF9aqL5qqHnMnVb2r0F5um/yJE7dPc qUfbWPlvffi7XOqWqMe0hPyV0U9jxeXurcv9v5hh7sOV7Y5ioa96drRm7W9f+U+JpTgj0VCL uag4EQCnc+oMWAIAAA== X-CMS-MailID: 20181210125256epcas1p1e4142cfefb9b21dfb8dad927fbd49143 X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20181210125256epcas1p1e4142cfefb9b21dfb8dad927fbd49143 References: <1544446204-5291-1-git-send-email-joshi.k@samsung.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch introduces "j_writehint" in JBD2 journal, which is set based by Ext4 depending on "journal_writehint" mount option (inspired from "journal_ioprio"). Signed-off-by: Kanchan Joshi --- fs/ext4/super.c | 33 +++++++++++++++++++++++++++------ fs/jbd2/commit.c | 11 +++++++---- fs/jbd2/journal.c | 2 +- fs/jbd2/revoke.c | 2 +- include/linux/jbd2.h | 7 +++++++ 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 53ff6c2..0283760 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1413,7 +1413,7 @@ enum { Opt_nowarn_on_error, Opt_mblk_io_submit, Opt_lazytime, Opt_nolazytime, Opt_debug_want_extra_isize, Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, - Opt_inode_readahead_blks, Opt_journal_ioprio, + Opt_inode_readahead_blks, Opt_journal_ioprio, Opt_journal_writehint, Opt_dioread_nolock, Opt_dioread_lock, Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache, @@ -1489,6 +1489,7 @@ static const match_table_t tokens = { {Opt_noblock_validity, "noblock_validity"}, {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, {Opt_journal_ioprio, "journal_ioprio=%u"}, + {Opt_journal_writehint, "journal_writehint=%u"}, {Opt_auto_da_alloc, "auto_da_alloc=%u"}, {Opt_auto_da_alloc, "auto_da_alloc"}, {Opt_noauto_da_alloc, "noauto_da_alloc"}, @@ -1677,6 +1678,7 @@ static const struct mount_opts { {Opt_journal_dev, 0, MOPT_NO_EXT2 | MOPT_GTE0}, {Opt_journal_path, 0, MOPT_NO_EXT2 | MOPT_STRING}, {Opt_journal_ioprio, 0, MOPT_NO_EXT2 | MOPT_GTE0}, + {Opt_journal_writehint, 0, MOPT_NO_EXT2 | MOPT_GTE0}, {Opt_data_journal, EXT4_MOUNT_JOURNAL_DATA, MOPT_NO_EXT2 | MOPT_DATAJ}, {Opt_data_ordered, EXT4_MOUNT_ORDERED_DATA, MOPT_NO_EXT2 | MOPT_DATAJ}, {Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA, @@ -1718,7 +1720,8 @@ static const struct mount_opts { static int handle_mount_opt(struct super_block *sb, char *opt, int token, substring_t *args, unsigned long *journal_devnum, - unsigned int *journal_ioprio, int is_remount) + unsigned int *journal_ioprio, + enum rw_hint *journal_writehint, int is_remount) { struct ext4_sb_info *sbi = EXT4_SB(sb); const struct mount_opts *m; @@ -1897,6 +1900,13 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, } *journal_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg); + } else if (token == Opt_journal_writehint) { + if (arg < WRITE_LIFE_NOT_SET || arg > WRITE_LIFE_EXTREME) { + ext4_msg(sb, KERN_ERR, "Invalid journal write hint" + " (must be 0-5)"); + return -1; + } + *journal_writehint = arg; } else if (token == Opt_test_dummy_encryption) { #ifdef CONFIG_EXT4_FS_ENCRYPTION sbi->s_mount_flags |= EXT4_MF_TEST_DUMMY_ENCRYPTION; @@ -1970,6 +1980,7 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, static int parse_options(char *options, struct super_block *sb, unsigned long *journal_devnum, unsigned int *journal_ioprio, + enum rw_hint *journal_writehint, int is_remount) { struct ext4_sb_info *sbi = EXT4_SB(sb); @@ -1990,7 +2001,8 @@ static int parse_options(char *options, struct super_block *sb, args[0].to = args[0].from = NULL; token = match_token(p, tokens, args); if (handle_mount_opt(sb, p, token, args, journal_devnum, - journal_ioprio, is_remount) < 0) + journal_ioprio, journal_writehint, + is_remount) < 0) return 0; } #ifdef CONFIG_QUOTA @@ -3534,6 +3546,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) int err = 0; unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; ext4_group_t first_not_zeroed; + enum rw_hint journal_writehint = WRITE_LIFE_NOT_SET; if ((data && !orig_data) || !sbi) goto out_free_base; @@ -3694,7 +3707,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) if (!s_mount_opts) goto failed_mount; if (!parse_options(s_mount_opts, sb, &journal_devnum, - &journal_ioprio, 0)) { + &journal_ioprio, &journal_writehint, 0)) { ext4_msg(sb, KERN_WARNING, "failed to parse options in superblock: %s", s_mount_opts); @@ -3703,7 +3716,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } sbi->s_def_mount_opt = sbi->s_mount_opt; if (!parse_options((char *) data, sb, &journal_devnum, - &journal_ioprio, 0)) + &journal_ioprio, &journal_writehint, 0)) goto failed_mount; if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { @@ -4265,6 +4278,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); + sbi->s_journal->j_writehint = journal_writehint; + sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; no_journal: @@ -5120,6 +5135,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) int enable_quota = 0; ext4_group_t g; unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; + enum rw_hint journal_writehint = WRITE_LIFE_NOT_SET; int err = 0; #ifdef CONFIG_QUOTA int i, j; @@ -5158,7 +5174,11 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) if (sbi->s_journal && sbi->s_journal->j_task->io_context) journal_ioprio = sbi->s_journal->j_task->io_context->ioprio; - if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) { + if (sbi->s_journal) + journal_writehint = sbi->s_journal->j_writehint; + + if (!parse_options(data, sb, NULL, &journal_ioprio, + &journal_writehint, 1)) { err = -EINVAL; goto restore_opts; } @@ -5221,6 +5241,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) if (sbi->s_journal) { ext4_init_journal_params(sb, sbi->s_journal); set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); + sbi->s_journal->j_writehint = journal_writehint; } if (*flags & SB_LAZYTIME) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 150cc03..8710afe 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -153,10 +153,12 @@ static int journal_submit_commit_record(journal_t *journal, if (journal->j_flags & JBD2_BARRIER && !jbd2_has_feature_async_commit(journal)) - ret = submit_bh(REQ_OP_WRITE, - REQ_SYNC | REQ_PREFLUSH | REQ_FUA, bh); + ret = submit_bh_write_hint(REQ_OP_WRITE, + REQ_SYNC | REQ_PREFLUSH | REQ_FUA, bh, + journal->j_writehint); else - ret = submit_bh(REQ_OP_WRITE, REQ_SYNC, bh); + ret = submit_bh_write_hint(REQ_OP_WRITE, REQ_SYNC, bh, + journal->j_writehint); *cbh = bh; return ret; @@ -708,7 +710,8 @@ void jbd2_journal_commit_transaction(journal_t *journal) clear_buffer_dirty(bh); set_buffer_uptodate(bh); bh->b_end_io = journal_end_buffer_io_sync; - submit_bh(REQ_OP_WRITE, REQ_SYNC, bh); + submit_bh_write_hint(REQ_OP_WRITE, REQ_SYNC, bh, + journal->j_writehint); } cond_resched(); stats.run.rs_blocks_logged += bufs; diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 8ef6b6d..f72ee4b 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1384,7 +1384,7 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags) jbd2_superblock_csum_set(journal, sb); get_bh(bh); bh->b_end_io = end_buffer_write_sync; - ret = submit_bh(REQ_OP_WRITE, write_flags, bh); + ret = submit_bh_write_hint(REQ_OP_WRITE, write_flags, bh, journal->j_writehint); wait_on_buffer(bh); if (buffer_write_io_error(bh)) { clear_buffer_write_io_error(bh); diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c index a1143e5..d4fd178 100644 --- a/fs/jbd2/revoke.c +++ b/fs/jbd2/revoke.c @@ -642,7 +642,7 @@ static void flush_descriptor(journal_t *journal, set_buffer_jwrite(descriptor); BUFFER_TRACE(descriptor, "write"); set_buffer_dirty(descriptor); - write_dirty_buffer(descriptor, REQ_SYNC); + write_dirty_buffer_write_hint(descriptor, REQ_SYNC, journal->j_writehint); } #endif diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index b708e51..0735ab0 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1138,6 +1138,13 @@ struct journal_s */ __u32 j_csum_seed; + /** + * @j_writehint: + * + * write hint for journal (set by fs). + */ + enum rw_hint j_writehint; + #ifdef CONFIG_DEBUG_LOCK_ALLOC /** * @j_trans_commit_map: