Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2677487ybb; Sat, 30 Mar 2019 10:51:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWQDH+1mAbHDsxWaDOrriwaSDqkEQKB6EB6vQ7wgcbL8mWPDDBMba/EIlRB24m/sbqVULF X-Received: by 2002:a62:e304:: with SMTP id g4mr12065392pfh.71.1553968266929; Sat, 30 Mar 2019 10:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553968266; cv=none; d=google.com; s=arc-20160816; b=YL542+7g7Kfqr4OMV8WDb6WUyJGiIPL8/d/10vraBTvZUdy69ioVsccwvQaB3ke1Dk z0N8b6SMJvZCmZgNAMLt3iEgzJLQRviKk9C01HCAahGKpgjD7ptma5ak8kopuM2V2t0h KCKLFNn1pG58bz1U2TMzYQo/n9DK5UaaRN+LIY1bdBCng60lFtTCBAS/UThiKm0evhEW IIo8vdypF1QM17FV0+QP+0My04jyikOrxHSfpoB4i752blxWck/vW6R1vfSB/GLsY4l0 DlcVz6NxvmRYlU0HEfwoQtOUuOMRX8UM9yBO2wbSVFiOOOTM9uLeK96H5uGrNdfg99+2 IXTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:to:cc:in-reply-to:date:subject :mime-version:message-id:from:dkim-signature; bh=8E+hSaYs/8++lmDMWklBVfbX6BTWou/pcJgdoUvO0os=; b=0+wh0LiWJ8QANwoy+dGIVpmYLbvuNS6dSzPP5g+PsRR+40jJvGbZA6KUXLXoAEAkoW MGBdp+SSj5BQ2WBGFeAjuUPmTxzIjo6y7jWSmBSM7oFAX0YK//Nbw1uM/pP3p3lXgBox sFkLXl991fzmSwnjAkCAB8h+ICyepkqx8y8nE61KApwRB8glFLf7Gp7DqqB3JVuLQxD3 DerV3aOsVnVjcma0ASfcZwdn9QHjdV3qHC7z/CNWzhtuSTlw6SPyNwTpbotHDRC8Id8Z 1TuQAchz6xUqsEywRGxmLNWL4h7kEVUolgJR01vZbQFBnNBOpgup2CoNPMYzMm54Kinh iTdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dilger-ca.20150623.gappssmtp.com header.s=20150623 header.b=QCa3yDb+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s29si4959251pga.152.2019.03.30.10.50.51; Sat, 30 Mar 2019 10:51:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@dilger-ca.20150623.gappssmtp.com header.s=20150623 header.b=QCa3yDb+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730877AbfC3Rt7 (ORCPT + 99 others); Sat, 30 Mar 2019 13:49:59 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46413 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730721AbfC3Rt7 (ORCPT ); Sat, 30 Mar 2019 13:49:59 -0400 Received: by mail-pl1-f194.google.com with SMTP id y6so2476910pll.13 for ; Sat, 30 Mar 2019 10:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dilger-ca.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=8E+hSaYs/8++lmDMWklBVfbX6BTWou/pcJgdoUvO0os=; b=QCa3yDb+iNw0osJacHzYOCRkgFfmkqDBKYlIfuVbgbhf7fHFe5p2uEu7aEuMtfHYqI JzmcN1DE6BSXUaPSL1X76c4g8W1wy7gP2Bkc176G3tEQd64lOfEGKCZmtb4jK2/CUerI UzrVw709m+w3SYVnKzS3hxH+wdWrnWPGESfJlfSeOqGmUU+Lc+urwnvvLOPqSQa3/r/r KPXpuUFsCR7zoAgIUIk2nPCp0dqpK4L6+PfVYMlNPCiSr3iJAPABR/de4LV2IdIEfxJa kZtIhzVYEg6PPU9aVbZ82MCleTRKmsxFhPGg58Jb7tDRPPQQNlDefpXRjivEK/E8nD4G ZNtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=8E+hSaYs/8++lmDMWklBVfbX6BTWou/pcJgdoUvO0os=; b=UE76oulh/i03Hg/afs01WQFm40pH2CKPelPrwPlvQzkSLGddSXvP7NHCGi1nT8sEza GrDejh0JXMH1BnmgUYpHiISQnMLYPI4o0K5Ku7nCMFxIP9uwBTcFir4e+yRkz0RzB2FT uXx/owZE9sdqxtAuOUnwwyVdfEAvwl+ORPL68DAkjAMQYiulxSBPgx/lFq1zIsWa7hqa 6Qgc1truJWAjT9tOY6IPQAHiDNwC2f2Yc4YplqDnrOT0pFAxc2DgO40rx5w+vdrMhBL0 gr9juZhF5dieprr7Mr3yNhkCMFlG27aedQyyeW0nvCiaXrSTVmI0zQhTVm8L2TB6lxQ/ 1xOg== X-Gm-Message-State: APjAAAWHhYMWFKurZ181IuSoGaLbYjIoq8aEOHUgRcVOvqkh3mSNL9Bq HyUr9T2TZ1xHjZEDWmmkHwidKw== X-Received: by 2002:a17:902:4681:: with SMTP id p1mr53635525pld.42.1553968198379; Sat, 30 Mar 2019 10:49:58 -0700 (PDT) Received: from cabot.adilger.ext (S0106a84e3fe4b223.cg.shawcable.net. [70.77.216.213]) by smtp.gmail.com with ESMTPSA id z8sm8346133pgz.3.2019.03.30.10.49.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Mar 2019 10:49:57 -0700 (PDT) From: Andreas Dilger Message-Id: <4B0B5E8B-3B30-4CF6-AA9D-D1294542D65D@dilger.ca> Content-Type: multipart/signed; boundary="Apple-Mail=_65735BA2-2B7A-4927-B12D-267E456AC8C8"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH v3 7/7] fs/ext4,jbd2: add support for passing write-hint with journal Date: Sat, 30 Mar 2019 11:49:54 -0600 In-Reply-To: <1553846032-4451-8-git-send-email-joshi.k@samsung.com> Cc: open list , linux-block , linux-nvme@lists.infradead.org, linux-fsdevel , linux-ext4@vger.kernel.org, axboe@fb.com, prakash.v@samsung.com, anshul@samsung.com, joshiiitr@gmail.com To: Kanchan Joshi References: <1553846032-4451-1-git-send-email-joshi.k@samsung.com> <1553846032-4451-8-git-send-email-joshi.k@samsung.com> X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Apple-Mail=_65735BA2-2B7A-4927-B12D-267E456AC8C8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Mar 29, 2019, at 1:53 AM, Kanchan Joshi wrote: >=20 > For NAND based SSDs, mixing of data with different life-time reduces > efficiency of internal garbage-collection. During FS operations, = series > of journal updates will follow/precede series of data/meta updates, = causing > intermixing inside SSD. By passing a write-hint with journal, its = write > can be isolated from other data/meta writes, leading to = endurance/performance > benefit on SSD. >=20 > This patch introduces "j_writehint" member in JBD2 journal, using = which > Ext4 specifies write-hint (as SHORT) for journal The comment here says the "WRITE_LIFE_SHORT" hint is used for the = journal, but the code uses WRITE_LIFE_KERN_MIN. However, it seems that "MIN" = will be mapped to "NONE" if it exceeds the number of streams available in the underlying device. It would be better to use "SHORT" if there are not enough streams available. It should call blk_queue_stream_limits() to see if there are extra = stream IDs available, and fall back to WRITE_LIFE_SHORT if not. Cheers, Andreas > Signed-off-by: Kanchan Joshi > --- > fs/ext4/ext4_jbd2.h | 1 + > fs/ext4/super.c | 2 ++ > fs/jbd2/commit.c | 11 +++++++---- > fs/jbd2/journal.c | 3 ++- > fs/jbd2/revoke.c | 3 ++- > include/linux/jbd2.h | 8 ++++++++ > 6 files changed, 22 insertions(+), 6 deletions(-) >=20 > diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h > index 15b6dd7..b589ca4 100644 > --- a/fs/ext4/ext4_jbd2.h > +++ b/fs/ext4/ext4_jbd2.h > @@ -16,6 +16,7 @@ > #include > #include "ext4.h" >=20 > +#define EXT4_JOURNAL_WRITE_HINT (WRITE_LIFE_KERN_MIN) > #define EXT4_JOURNAL(inode) (EXT4_SB((inode)->i_sb)->s_journal) >=20 > /* Define the number of blocks we need to account to a transaction to > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index fb12d3c..9c2c73e 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -4289,6 +4289,8 @@ static int ext4_fill_super(struct super_block = *sb, void *data, int silent) >=20 > set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); >=20 > + sbi->s_journal->j_writehint =3D EXT4_JOURNAL_WRITE_HINT; > + > sbi->s_journal->j_commit_callback =3D = ext4_journal_commit_callback; >=20 > no_journal: > diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c > index 2eb55c3..6da4c28 100644 > --- a/fs/jbd2/commit.c > +++ b/fs/jbd2/commit.c > @@ -153,10 +153,12 @@ static int = journal_submit_commit_record(journal_t *journal, >=20 > if (journal->j_flags & JBD2_BARRIER && > !jbd2_has_feature_async_commit(journal)) > - ret =3D submit_bh(REQ_OP_WRITE, > - REQ_SYNC | REQ_PREFLUSH | REQ_FUA, bh); > + ret =3D submit_bh_write_hint(REQ_OP_WRITE, > + REQ_SYNC | REQ_PREFLUSH | REQ_FUA, bh, > + journal->j_writehint); > else > - ret =3D submit_bh(REQ_OP_WRITE, REQ_SYNC, bh); > + ret =3D submit_bh_write_hint(REQ_OP_WRITE, REQ_SYNC, bh, > + journal->j_writehint); >=20 > *cbh =3D bh; > return ret; > @@ -711,7 +713,8 @@ void jbd2_journal_commit_transaction(journal_t = *journal) > clear_buffer_dirty(bh); > set_buffer_uptodate(bh); > bh->b_end_io =3D = 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 +=3D bufs; > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c > index 8ef6b6d..804dc2c 100644 > --- a/fs/jbd2/journal.c > +++ b/fs/jbd2/journal.c > @@ -1384,7 +1384,8 @@ static int jbd2_write_superblock(journal_t = *journal, int write_flags) > jbd2_superblock_csum_set(journal, sb); > get_bh(bh); > bh->b_end_io =3D end_buffer_write_sync; > - ret =3D submit_bh(REQ_OP_WRITE, write_flags, bh); > + ret =3D 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..376b1d8 100644 > --- a/fs/jbd2/revoke.c > +++ b/fs/jbd2/revoke.c > @@ -642,7 +642,8 @@ 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_with_hint(descriptor, REQ_SYNC, > + journal->j_writehint); > } > #endif >=20 > diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h > index 0f919d5..918f21e 100644 > --- a/include/linux/jbd2.h > +++ b/include/linux/jbd2.h > @@ -1139,6 +1139,14 @@ struct journal_s > */ > __u32 j_csum_seed; >=20 > + /** > + * @j_writehint: > + * > + * write-hint for journal (set by FS). > + */ > + enum rw_hint j_writehint; > + > + > #ifdef CONFIG_DEBUG_LOCK_ALLOC > /** > * @j_trans_commit_map: > -- > 2.7.4 >=20 Cheers, Andreas --Apple-Mail=_65735BA2-2B7A-4927-B12D-267E456AC8C8 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIzBAEBCAAdFiEEDb73u6ZejP5ZMprvcqXauRfMH+AFAlyfrEMACgkQcqXauRfM H+Awog//R0q+wZ7sWDziORQpf4h0sVTnHqSOZIqEoU/iIdGKX4u7Pj4VoBTnc8o/ Jd+MS8J0dioOzU6Pg3yU0vX7Ic38VBLGV4ORpRg5xOqG3EDHU2hzO73VEQokSUPK vphNY7J6EJJWRWb8oD2inEWh2RZQ93y/MCjhZS3K2PVW5EqfrN7USfomzNE1LPnv L3sStO3rCafsAwW8N46BJF4gscgW2Xk2K885XV2Uy4MPIcM6MjbVrn7xd5VDTfxx T+XwHLGtEz1UOe5/U/+YkxbvjDpj7r3xqZ9OpEnsL0ozlIR5B21L12qCVdxCJwWn L+yKsECM68yWDFKN8+s8YEnGjNUx+A5wQSDJL5Zcxa3ahFIL/RX5ivUEgq10f5JU 1QOyeFd/fyBbhjFTwzsvKh78dcNpAKPZ5IpQJ66sMNJXeG1rXjaqW0i3nRbJYzYi CypU0e0pAPzFzJ+a2g881zPXPtIvmqL0nlp2FPdYXtfqkVADyqlW67R7TJuh3+oZ vNND3y0AlmvDKA8B+G4Z8PSPhcFX14pVKGocvSKwk8BIR0EPaHdqLiLAmSiqlnN0 lXrRSNjn2QUqpWhcKDYjErkgo7GLB1nRnYzrGGTQ+zg8KACmqlbDunjubyDAPkO+ y0byklIvIi6UdV6BI4WnpC2k6RSR3EZcGR5EmZBGjueLFWK/sqM= =+O2I -----END PGP SIGNATURE----- --Apple-Mail=_65735BA2-2B7A-4927-B12D-267E456AC8C8--