From patchwork Tue Sep 10 15:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 827290 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12935190692 for ; Tue, 10 Sep 2024 15:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981052; cv=none; b=DlLvxJDeHO+A4qDCzxSV6PElYUShbqse1OUzISt601WL4mUxO12pNW0/HDElDS2F9djE/P/VMZo2vzQzKlqlkTC3hRHTMNN8Zd9nc0VAymPf54QSijImj5jN+mtcCkM67FdEYUBtBg0rcZmZ3a51FN/+fLyqWQyy5hcDAAdgCBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981052; c=relaxed/simple; bh=EOmyo3LNS2sTILpDdwkz/wbfnmkFCFhWqsu2zsG1LCY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=l2JXQ+y2VSej17FdWDJCi9hX6Gcf3ipWLVHW8jrxlRIfUFmWXhevxkQGB0890ANVgpRgp2RWRsZpG5HO6DVn+BMo4tDZnAMbaO/vWJQQrZxqA2yulDSSZ97tjV+ywAOdgxTJLTzJ/wz5BHXy1XV7KHFxUQaekVIGBAZH7EnnvYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=MR1lVlYz; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="MR1lVlYz" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240910151047epoutp0433dd2c7494c755021202a13e85d5fa73~z6p40nrFq1894418944epoutp04d for ; Tue, 10 Sep 2024 15:10:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240910151047epoutp0433dd2c7494c755021202a13e85d5fa73~z6p40nrFq1894418944epoutp04d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725981047; bh=/IM9kt/2eCM14q1kv/IUC0Orm6DmaZVmcMJa34MEri8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MR1lVlYzSD30VBZtqx069poLYGBIZLK5q2LoQsmR4/5PjZgQq5XjNcsW6dFHKHZsh st2K8WomT9u1XxFawNn/w49JQH56GF2fCTbM1dgbPW5G2GWLSmrhyXxbqxC0cKix9i BILLPEeIseL5wjRSStmAhyp87tallMsNMrxZ6FtM= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240910151046epcas5p2a26321e41189a2f101cae5ce738de816~z6p4O1QG30258802588epcas5p2V; Tue, 10 Sep 2024 15:10:46 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4X36b90Hwwz4x9Pp; Tue, 10 Sep 2024 15:10:45 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id E8.6F.19863.47160E66; Wed, 11 Sep 2024 00:10:44 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240910151044epcas5p37f61bb85ccf8b3eb875e77c3fc260c51~z6p1zgmQ13222332223epcas5p3C; Tue, 10 Sep 2024 15:10:44 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240910151044epsmtrp12aae38aee9b01960e33fb0a7289f047d~z6p1ylVlM1255512555epsmtrp1i; Tue, 10 Sep 2024 15:10:44 +0000 (GMT) X-AuditID: b6c32a50-ef5fe70000004d97-3d-66e0617422f1 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 06.F3.19367.47160E66; Wed, 11 Sep 2024 00:10:44 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240910151040epsmtip21920684c4863f20fece9a37c05cd1b85~z6pyAtglJ1772517725epsmtip2M; Tue, 10 Sep 2024 15:10:39 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jaegeuk@kernel.org, jlayton@kernel.org, chuck.lever@oracle.com, bvanassche@acm.org Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, gost.dev@samsung.com, vishak.g@samsung.com, javier.gonz@samsung.com, Kanchan Joshi Subject: [PATCH v5 1/5] fs, block: refactor enum rw_hint Date: Tue, 10 Sep 2024 20:31:56 +0530 Message-Id: <20240910150200.6589-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910150200.6589-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List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anZqakFqEUyWiYNTqoEpWH3BLjfu3fVNtzP5 LfcZvZ1sf/ZxD7Pukgv+7AyrZplfkWuV29gVJLP06sYkvzcSh/4f6vmzbmUOr7VZmouS3h2F 0CaRhu5NrKUzrjMfVw314J7oMVnueo6E+gs/yVLfqUmHLpqF/Xz3yYZdQeSYbtmVtGVLXhQu lPhhpZc+bUPz5f/c89/Z6V+SiTcJWca+viP5Ye+ZaXohv9PcdsXfMP7ZWcjgYCOxaF2kwOcz /5wt4sXkix5ynXBPCb8uGzBvjeHKsGsMstcU5rzy3BjYq77w66q1IoWS6wN/xxysfPXD97nx T9HvOh55PULfTj7VOp/CG/tio1xa0Jzm9CsbhLJ4Du6VWr7hgNmXjgdKLMUZiYZazEXFiQBZ huDzQwMAAA== X-CMS-MailID: 20240910151044epcas5p37f61bb85ccf8b3eb875e77c3fc260c51 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240910151044epcas5p37f61bb85ccf8b3eb875e77c3fc260c51 References: <20240910150200.6589-1-joshi.k@samsung.com> Rename enum rw_hint to rw_lifetime_hint. Change i_write_hint (in inode), bi_write_hint(in bio), and write_hint (in request) to use u8 data-type rather than this enum. This is in preparation to introduce a new write hint type. Signed-off-by: Kanchan Joshi --- fs/buffer.c | 4 ++-- fs/f2fs/f2fs.h | 5 +++-- fs/f2fs/segment.c | 5 +++-- include/linux/blk-mq.h | 2 +- include/linux/blk_types.h | 2 +- include/linux/fs.h | 2 +- include/linux/rw_hint.h | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index e55ad471c530..0c6bc9b7d4ad 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -55,7 +55,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh, - enum rw_hint hint, struct writeback_control *wbc); + u8 hint, struct writeback_control *wbc); #define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers) @@ -2778,7 +2778,7 @@ static void end_bio_bh_io_sync(struct bio *bio) } static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh, - enum rw_hint write_hint, + u8 write_hint, struct writeback_control *wbc) { const enum req_op op = opf & REQ_OP_MASK; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ac19c61f0c3e..9b843b57dba1 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3756,8 +3756,9 @@ int f2fs_build_segment_manager(struct f2fs_sb_info *sbi); void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi); int __init f2fs_create_segment_manager_caches(void); void f2fs_destroy_segment_manager_caches(void); -int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint); -enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, +int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, + enum rw_lifetime_hint hint); +enum rw_lifetime_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, enum page_type type, enum temp_type temp); unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, unsigned int segno); diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 78c3198a6308..6802e82f9ffd 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3381,7 +3381,8 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) return err; } -int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint) +int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, + enum rw_lifetime_hint hint) { if (F2FS_OPTION(sbi).active_logs == 2) return CURSEG_HOT_DATA; @@ -3425,7 +3426,7 @@ int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint) * WRITE_LIFE_MEDIUM " WRITE_LIFE_MEDIUM * WRITE_LIFE_LONG " WRITE_LIFE_LONG */ -enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, +enum rw_lifetime_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, enum page_type type, enum temp_type temp) { switch (type) { diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 8d304b1d16b1..1e5ce84ccf0a 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -159,7 +159,7 @@ struct request { struct blk_crypto_keyslot *crypt_keyslot; #endif - enum rw_hint write_hint; + u8 write_hint; unsigned short ioprio; enum mq_rq_state state; diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 36ed96133217..446c847bb3b3 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -216,7 +216,7 @@ struct bio { */ unsigned short bi_flags; /* BIO_* below */ unsigned short bi_ioprio; - enum rw_hint bi_write_hint; + u8 bi_write_hint; blk_status_t bi_status; atomic_t __bi_remaining; diff --git a/include/linux/fs.h b/include/linux/fs.h index fb0426f349fc..f9a7a2a80661 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -674,7 +674,7 @@ struct inode { spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ unsigned short i_bytes; u8 i_blkbits; - enum rw_hint i_write_hint; + u8 i_write_hint; blkcnt_t i_blocks; #ifdef __NEED_I_SIZE_ORDERED diff --git a/include/linux/rw_hint.h b/include/linux/rw_hint.h index 309ca72f2dfb..b9942f5f13d3 100644 --- a/include/linux/rw_hint.h +++ b/include/linux/rw_hint.h @@ -7,7 +7,7 @@ #include /* Block storage write lifetime hint values. */ -enum rw_hint { +enum rw_lifetime_hint { WRITE_LIFE_NOT_SET = RWH_WRITE_LIFE_NOT_SET, WRITE_LIFE_NONE = RWH_WRITE_LIFE_NONE, WRITE_LIFE_SHORT = RWH_WRITE_LIFE_SHORT, @@ -18,7 +18,7 @@ enum rw_hint { /* Sparse ignores __packed annotations on enums, hence the #ifndef below. */ #ifndef __CHECKER__ -static_assert(sizeof(enum rw_hint) == 1); +static_assert(sizeof(enum rw_lifetime_hint) == 1); #endif #endif /* _LINUX_RW_HINT_H */ From patchwork Tue Sep 10 15:01:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 827679 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA33519992A for ; Tue, 10 Sep 2024 15:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981054; cv=none; b=npMjkJlJoEJ/iUo5sw6H2gR+6MnQQBB4cDE5E9SZYzW2DiM+hzGRR2mHByBrc8liMnygspRko4PBd64LLW1DWy1/UWiBeltsOImVOw/11nxwCNLeQYBHQt15+OkXR6g5qqP/1veAcFmHAAD6sFet8l2nku2Y26zZixKe8QCDMKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981054; c=relaxed/simple; bh=ov6xA9K9iXGpqQlTQm6tmG7h9eDDCdtk808oP4zJnxE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=iG0NJC0Skq56Ekf5RKcy6Ism12ewSLFLQt0kx70+iMFXO/zDGC0RnUnjCnDkt7wwEv5TYW7csHQJJV7KT0zQhJtekgKYQXBsONHe+UyYySs6tN0qc4YUKPNd+p1cPd4JepgUytnZdI7C6s1k6L/voqMMg9ufaTUZYL5xM38vdH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=l7UJGCwD; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="l7UJGCwD" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240910151050epoutp02d2721fa8244370be131109bc80e95845~z6p8IW_pF2252922529epoutp02j for ; Tue, 10 Sep 2024 15:10:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240910151050epoutp02d2721fa8244370be131109bc80e95845~z6p8IW_pF2252922529epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725981051; bh=pMYjZwpNA2424mhqR5If5Z9/oTINVKlEa7d3jWpwtNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7UJGCwDN4SiSuTrx6hJPODsaAQgHZlKK4WJMcPNSTRmfusfcAKXPr+G+Nq5jDkex YSoroUbwMCW4UrBs2VZKpelkX3MIRobVQ8BqDC21P+keybJhHJi+sBHHcRqPREgz93 uqIvu/PNMgjlpFWN0mjPbl0SpZssXTzG3F881AWg= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240910151050epcas5p179ff3d5c1a23344350ef986991a1f492~z6p7VY4Pn0608306083epcas5p1F; Tue, 10 Sep 2024 15:10:50 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4X36bD6pwfz4x9Ps; Tue, 10 Sep 2024 15:10:48 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4B.86.09640.87160E66; Wed, 11 Sep 2024 00:10:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240910151048epcas5p3c610d63022362ec5fcc6fc362ad2fb9f~z6p5sWm3Y0202102021epcas5p3K; Tue, 10 Sep 2024 15:10:48 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240910151048epsmtrp1f4f0e75e2c26af28a4bad11e3192301c~z6p5rfzf-1279412794epsmtrp1C; Tue, 10 Sep 2024 15:10:48 +0000 (GMT) X-AuditID: b6c32a49-aabb8700000025a8-69-66e06178b9ab Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 29.DC.08964.87160E66; Wed, 11 Sep 2024 00:10:48 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240910151044epsmtip2969e9e84906072571198d274c61a89e4~z6p19uGJ71712417124epsmtip2t; Tue, 10 Sep 2024 15:10:44 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jaegeuk@kernel.org, jlayton@kernel.org, chuck.lever@oracle.com, bvanassche@acm.org Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, gost.dev@samsung.com, vishak.g@samsung.com, javier.gonz@samsung.com, Kanchan Joshi Subject: [PATCH v5 2/5] fcntl: rename rw_hint_* to rw_lifetime_hint_* Date: Tue, 10 Sep 2024 20:31:57 +0530 Message-Id: <20240910150200.6589-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910150200.6589-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02TbUxbVRzGc+4t7WVSvCsTDjVseB1LQF7aCeWgsC3ayTXsA8liTPZBuKOX Qlra2ttuQCRDkCowB2IGo7yIuPE6N3lnQxJlq4gOQTYZMN4FmYOlUAKGDIYtZbpvv/M/z3P+ 5zkvBC5a4YuJZI2B1WsYNcXfw2u/5R8QlMpMJ0pWCyWocaKAjxZv2QAqXt7A0fbEAoZGf7iB ofpGC4bKSrIxNHfdjKOmAgL9Ob4qQBs1DQJk2X7MR0U9wwB1j72Ghqqj0ffdfTz0Vc28AOXf 7+Sj2t6nGLq2aOWhga1eFzRgLhcc86Tv3ouhByabeHRx0S98+m6/kW5uyOXTLZfP0V1Vqxjd NZrJp1fmx3j0hdYGQN+pui2gV5v3081zj7FY4SlVZBLLKFi9L6tJ0CqSNcooKuZk3NtxYTKJ NEgagcIpXw2TwkZR8hOxQe8kq+2ZKd8zjNpoL8UyHEeFHInUa40G1jdJyxmiKFanUOtCdcEc k8IZNcpgDWt4QyqRHA6zC+NVSev5Vlxn2pu6NNgNMsGSMA+4EpAMhTMPanh5YA8hIrsArNn4 FXcObABey2oHzsE6gNtN9eCZZfiPqV1VN4CtAw8EjgkRuQpgbtZbeYAg+KQ/HPzS6NDsIysx +NOgZWclnCzC4Mr0t3yHwYM8DhcXnuAO5pF+cOq7xp26kAyH6yPnBc5uB2Dp0D877EoiuFB7 FXNq9sK+0jmeg3G7JrutbGdHkMx3hRUdm3ynWQ7LyocwJ3vAR72tu4uK4d8Fpl1WwenZaZ6T P4KdLRdcnHwUZm6OuDjS4PY012+GOHu5w8+fzGGOMiSF8DOTyKl+BU4Wze86veDMpcu7TMNR a6uL87DyAVzbvIEVggPm5yKYn4tg/r9bFcAbgDer41KULBemk2r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j3oYuFY49Dkuk/0 k+nqrHbcxdhYn/QwG7sAKO1/SvufygVQB6ZxMoUkWqIIkYVIuSPBClaiUEqjgyPiJEYwfuyc 2Y9Bsc4RbAKQBCZAk5jYW6AJa44SCiLZY8c5edweuTKWU5iAH4mLfQQ+nepIIRXNxnMHOU7G yf9ZSHr4JsLruphiLvzJrCVKa1bmvmai6ROZFK4O3XLJTor2nfb6umF3uuXkW1KFV3Z/GU7I P1R/zSFPmxnkfxH0atb0nM/JvLkyecTk1zYvTbHMd8/mbwMZM7hpjT7uRaraGreHyVb4fJnB 4l2SvzyCtULzT/nSRZcvhK72DPogCjLHHfzYuXZ4uv7TrnVemeqN3juPlzhPBW02idU2uG1I pyUWlIXXiCWxFaZW/vdvTqkscJto04Z7hcZU1c7rT8/49kWcMDj9p1iqRC9f2T23vp7kyKqS qg2li7Y4YU4o6Ta4Y+hsbWdUd5tbS3bTiPiax40dB0Q9hasWFpgzVYGCBlZXphfjiv1syBxM rmD/AE2dcMxHAwAA X-CMS-MailID: 20240910151048epcas5p3c610d63022362ec5fcc6fc362ad2fb9f X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240910151048epcas5p3c610d63022362ec5fcc6fc362ad2fb9f References: <20240910150200.6589-1-joshi.k@samsung.com> F_GET/SET_RW_HINT fcntl handlers query/set write life hints. Rename the handlers/helpers to be explicit that write life hints are being handled. This is in preparation to introduce a new interface that supports more than one type of write hint. Signed-off-by: Kanchan Joshi --- fs/fcntl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index 300e5d9ad913..9df35e7ff754 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -269,7 +269,7 @@ static int f_getowner_uids(struct file *filp, unsigned long arg) } #endif -static bool rw_hint_valid(u64 hint) +static bool rw_lifetime_hint_valid(u64 hint) { BUILD_BUG_ON(WRITE_LIFE_NOT_SET != RWH_WRITE_LIFE_NOT_SET); BUILD_BUG_ON(WRITE_LIFE_NONE != RWH_WRITE_LIFE_NONE); @@ -291,7 +291,7 @@ static bool rw_hint_valid(u64 hint) } } -static long fcntl_get_rw_hint(struct file *file, unsigned int cmd, +static long fcntl_get_rw_lifetime_hint(struct file *file, unsigned int cmd, unsigned long arg) { struct inode *inode = file_inode(file); @@ -303,7 +303,7 @@ static long fcntl_get_rw_hint(struct file *file, unsigned int cmd, return 0; } -static long fcntl_set_rw_hint(struct file *file, unsigned int cmd, +static long fcntl_set_rw_lifetime_hint(struct file *file, unsigned int cmd, unsigned long arg) { struct inode *inode = file_inode(file); @@ -312,7 +312,7 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd, if (copy_from_user(&hint, argp, sizeof(hint))) return -EFAULT; - if (!rw_hint_valid(hint)) + if (!rw_lifetime_hint_valid(hint)) return -EINVAL; WRITE_ONCE(inode->i_write_hint, hint); @@ -449,10 +449,10 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, err = memfd_fcntl(filp, cmd, argi); break; case F_GET_RW_HINT: - err = fcntl_get_rw_hint(filp, cmd, arg); + err = fcntl_get_rw_lifetime_hint(filp, cmd, arg); break; case F_SET_RW_HINT: - err = fcntl_set_rw_hint(filp, cmd, arg); + err = fcntl_set_rw_lifetime_hint(filp, cmd, arg); break; default: break; From patchwork Tue Sep 10 15:01:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 827289 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C4BD19A28B for ; Tue, 10 Sep 2024 15:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981060; cv=none; b=Kege4KOVPvuZaP0dJMnSuGkZG1qvs2o1QnMLJt8dMNAnwUMyAJuNYdF/O+3gEaFhQviN3WAM67XtJ5XmQCddYwl/VD0L5kwsJaAbciGJvG65RnCHX2Mbe0Q7zSarEogiwd0pQiRqAsVFY9VBCyiLjWYztl4W6gkNncCYm+4uQcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981060; c=relaxed/simple; bh=PdlMtVh3kA8cEiEfQP5dtFdZxpBxO1u8rVqwOT+VdYg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=s9QavqfG3buM3tl0Vp5rDJlnR8+MEh9DJFSn4G4wRnfifZFcgoGlcCB7DDRUh21qObXfC07sqBRCnips1fQGG8JZlc4R+kMvB8iK43JB5DrBUbyhT0hM7UjxJLhU2Oe9swGrNxmOB9jsGBzIVWEk/9sRbhdFmMn4fW02XD8epm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=XWuaHULK; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="XWuaHULK" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240910151056epoutp0472107c43e5bd5484e31d9718e9ec8577~z6qBdmiB71846118461epoutp04K for ; Tue, 10 Sep 2024 15:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240910151056epoutp0472107c43e5bd5484e31d9718e9ec8577~z6qBdmiB71846118461epoutp04K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725981056; bh=7ZDBUnzd4Ndq1SXpxq73aCV6Tou4ScFnpQdbc8edz+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XWuaHULK8u5CEz/yAfGPiGBuillrBcfPeDozBn+Sl5pARgjKOWWzsVPa9dOgkmOqn lngRazMdCbEb4WtBkaOMOcZuIDL46b3D5RzOmXFYFlTnJcrr4l5uKDRw6dBUzspp/Z yVEYj89i66SUadcbE+WoH53YOg/QtIfgEyp8kFPI= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240910151055epcas5p322e74b1ad79c7d50fe80f02223ad85cf~z6qAMvLXq0202102021epcas5p3b; Tue, 10 Sep 2024 15:10:55 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.176]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4X36bK4LRSz4x9Ps; Tue, 10 Sep 2024 15:10:53 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 62.3A.09642.D7160E66; Wed, 11 Sep 2024 00:10:53 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20240910151052epcas5p48b20962753b1e3171daf98f050d0b5af~z6p93-Ma70472804728epcas5p4E; Tue, 10 Sep 2024 15:10:52 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240910151052epsmtrp23a0eca1b0398a1db4744b42444571d43~z6p92Cuow0449204492epsmtrp2i; Tue, 10 Sep 2024 15:10:52 +0000 (GMT) X-AuditID: b6c32a4b-879fa700000025aa-8a-66e0617d468b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 16.6C.08456.C7160E66; Wed, 11 Sep 2024 00:10:52 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240910151048epsmtip27e0cdbfdc338abc336e324f187c4a686~z6p53LRxJ1712417124epsmtip2u; Tue, 10 Sep 2024 15:10:48 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jaegeuk@kernel.org, jlayton@kernel.org, chuck.lever@oracle.com, bvanassche@acm.org Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, gost.dev@samsung.com, vishak.g@samsung.com, javier.gonz@samsung.com, Kanchan Joshi , Nitesh Shetty Subject: [PATCH v5 3/5] fcntl: add F_{SET/GET}_RW_HINT_EX Date: Tue, 10 Sep 2024 20:31:58 +0530 Message-Id: <20240910150200.6589-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910150200.6589-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te0xbVRzHuY/elpnqXYfjrHEOq2K6Skel7Q4bMNxQrrJEnDNm4gINvVCk L/oQhpoxmYZBBgpkSBkPzQKOKYy2Q1jHtrQCghhwvAkQZGXokIHUMNhDbLmo++/7O/l8z+98 f+ccDsbzEHxOmtZEG7QKtYDYhDe7hMKQjxVTKaG99wLhhYkiAs65lhB4ZnEVg2sTsygcvd6K wvMX2lFYUZaLQnejBYNNRRx4c9zDhqu19WzYvjZPwGLnEALb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TL7vmdT RX2nem4r9l6rolWofHv141kPGWsEApV6Ur5WLdl4/DHPG0EXzcb+nVyZYSG85/y+iUQ6NKoq sRRnJBpqMRcVJwIACku/w0sDAAA= X-CMS-MailID: 20240910151052epcas5p48b20962753b1e3171daf98f050d0b5af X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240910151052epcas5p48b20962753b1e3171daf98f050d0b5af References: <20240910150200.6589-1-joshi.k@samsung.com> This is similar to existing F_{SET/GET}_RW_HINT but more generic/extensible. F_SET/GET_RW_HINT_EX take a pointer to a struct rw_hint_ex as argument: struct rw_hint_ex { __u8 type; __u8 pad[7]; __u64 val; }; With F_SET_RW_HINT_EX, the user passes the hint type and its value. Hint type can be either lifetime hint (TYPE_RW_LIFETIME_HINT) or placement hint (TYPE_RW_PLACEMENT_HINT). The interface allows to add more hint add more hint types in future. Valid values for life hints are same as values supported by existing fcntl(F_SET_RW_HINT). Valid values for placement hints are between 0 to 126, both inclusive. The inode retains either the lifetime hint or the placement hint, whichever is set later. The set hint type and its value can be queried by F_GET_RW_HINT_EX. The i_write_hint field of the inode is a 1-byte field. Use the most significant bit as the hint type. This bit is set for placement hint. For lifetime hint, this bit remains zero. Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty --- fs/fcntl.c | 67 ++++++++++++++++++++++++++++++++++++++ include/linux/rw_hint.h | 13 ++++++++ include/uapi/linux/fcntl.h | 14 ++++++++ 3 files changed, 94 insertions(+) diff --git a/fs/fcntl.c b/fs/fcntl.c index 9df35e7ff754..b35aec56981a 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -291,6 +291,14 @@ static bool rw_lifetime_hint_valid(u64 hint) } } +static inline bool rw_placement_hint_valid(u64 val) +{ + if (val <= MAX_PLACEMENT_HINT_VAL) + return true; + + return false; +} + static long fcntl_get_rw_lifetime_hint(struct file *file, unsigned int cmd, unsigned long arg) { @@ -327,6 +335,59 @@ static long fcntl_set_rw_lifetime_hint(struct file *file, unsigned int cmd, return 0; } +static long fcntl_get_rw_hint_ex(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct rw_hint_ex __user *rw_hint_ex_p = (void __user *)arg; + struct rw_hint_ex rwh = {}; + struct inode *inode = file_inode(file); + u8 hint = READ_ONCE(inode->i_write_hint); + + rwh.type = WRITE_HINT_TYPE(hint); + rwh.val = WRITE_HINT_VAL(hint); + + if (copy_to_user(rw_hint_ex_p, &rwh, sizeof(rwh))) + return -EFAULT; + + return 0; +} + +static long fcntl_set_rw_hint_ex(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct rw_hint_ex __user *rw_hint_ex_p = (void __user *)arg; + struct rw_hint_ex rwh; + struct inode *inode = file_inode(file); + u64 hint; + int i; + + if (copy_from_user(&rwh, rw_hint_ex_p, sizeof(rwh))) + return -EFAULT; + for (i = 0; i < ARRAY_SIZE(rwh.pad); i++) + if (rwh.pad[i]) + return -EINVAL; + switch (rwh.type) { + case TYPE_RW_LIFETIME_HINT: + if (!rw_lifetime_hint_valid(rwh.val)) + return -EINVAL; + hint = rwh.val; + break; + case TYPE_RW_PLACEMENT_HINT: + if (!rw_placement_hint_valid(rwh.val)) + return -EINVAL; + hint = PLACEMENT_HINT_TYPE | rwh.val; + break; + default: + return -EINVAL; + } + + WRITE_ONCE(inode->i_write_hint, hint); + if (file->f_mapping->host != inode) + WRITE_ONCE(file->f_mapping->host->i_write_hint, hint); + + return 0; +} + /* Is the file descriptor a dup of the file? */ static long f_dupfd_query(int fd, struct file *filp) { @@ -454,6 +515,12 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, case F_SET_RW_HINT: err = fcntl_set_rw_lifetime_hint(filp, cmd, arg); break; + case F_GET_RW_HINT_EX: + err = fcntl_get_rw_hint_ex(filp, cmd, arg); + break; + case F_SET_RW_HINT_EX: + err = fcntl_set_rw_hint_ex(filp, cmd, arg); + break; default: break; } diff --git a/include/linux/rw_hint.h b/include/linux/rw_hint.h index b9942f5f13d3..ff708a75e2f6 100644 --- a/include/linux/rw_hint.h +++ b/include/linux/rw_hint.h @@ -21,4 +21,17 @@ enum rw_lifetime_hint { static_assert(sizeof(enum rw_lifetime_hint) == 1); #endif +#define WRITE_HINT_TYPE_BIT BIT(7) +#define WRITE_HINT_VAL_MASK (WRITE_HINT_TYPE_BIT - 1) +#define WRITE_HINT_TYPE(h) (((h) & WRITE_HINT_TYPE_BIT) ? \ + TYPE_RW_PLACEMENT_HINT : TYPE_RW_LIFETIME_HINT) +#define WRITE_HINT_VAL(h) ((h) & WRITE_HINT_VAL_MASK) + +#define WRITE_PLACEMENT_HINT(h) (((h) & WRITE_HINT_TYPE_BIT) ? \ + WRITE_HINT_VAL(h) : 0) +#define WRITE_LIFETIME_HINT(h) (((h) & WRITE_HINT_TYPE_BIT) ? \ + 0 : WRITE_HINT_VAL(h)) + +#define PLACEMENT_HINT_TYPE WRITE_HINT_TYPE_BIT +#define MAX_PLACEMENT_HINT_VAL (WRITE_HINT_VAL_MASK - 1) #endif /* _LINUX_RW_HINT_H */ diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index c0bcc185fa48..f758a7230419 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -57,6 +57,8 @@ #define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12) #define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13) #define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14) +#define F_GET_RW_HINT_EX (F_LINUX_SPECIFIC_BASE + 15) +#define F_SET_RW_HINT_EX (F_LINUX_SPECIFIC_BASE + 16) /* * Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be @@ -76,6 +78,18 @@ */ #define RWF_WRITE_LIFE_NOT_SET RWH_WRITE_LIFE_NOT_SET +enum rw_hint_type { + TYPE_RW_LIFETIME_HINT = 1, + TYPE_RW_PLACEMENT_HINT +}; + +/* Exchange information with F_{GET/SET}_RW_HINT fcntl */ +struct rw_hint_ex { + __u8 type; + __u8 pad[7]; + __u64 val; +}; + /* * Types of directory notifications that may be requested. */ From patchwork Tue Sep 10 15:01:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 827678 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A818199952 for ; Tue, 10 Sep 2024 15:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981065; cv=none; b=X2yvLUKa233QehPV6HDy42p4zo/Cdd2i7AHymvpA6pusgtHmYJq+Mo6WozYtSBJeaI+Es7lq8G4x1slqE8Tp/bUTizA/wrwCuB2CfLI7yI+4RkUvvJa7aFPy2yrG9zEFXBWIdR4P8APkIfC4+M7te6a1pv1uWrN4RGSLBjhec3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981065; c=relaxed/simple; bh=0BcmOldoB+WCX31xfylNUt7pSKNOVFJfJRF4uZUT0pM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=jDkBoLua8an2ahd+ZArd+Jil0sTowytDb9ZELmEhdMMK/fBBQhs4M5mDBcTjN2fzAAfSy3GZ9XJkORK4Si2FoAZrV2IZb9VrrUMnFRe9OoGXXq9kjeGr2Id1zc7FqhJvchJ/QDJWeMDp+m679zrhaRriFjcXcpyZwQBcu3imcAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=lzD0bH/D; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="lzD0bH/D" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240910151101epoutp02c431494df4a7d68fc509d12d17e2875a~z6qF1fkcD2368423684epoutp02y for ; Tue, 10 Sep 2024 15:11:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240910151101epoutp02c431494df4a7d68fc509d12d17e2875a~z6qF1fkcD2368423684epoutp02y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725981061; bh=kDAlnsSf6+fQcESYLjvnBr4Ul7FSOPIoyRTSELKQNY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzD0bH/DyhG9JSoiUA6y0vgKdmCRz9nZ7S+vyxUxDhxf0AEPXiiOjZBBV3XB6EiJ6 m47D9953n+81Y6d7IYrH6p4F4WAgSqNrr9lWRZZXVkfQk841U2B7fJjdJsYbLlh32T 5vfYytHIa+EaUznHwjarBvZju7cHzUQickfmOe30= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240910151100epcas5p2681730c3de752f6820679dcd4fe7927e~z6qFEM1LQ2551025510epcas5p2m; Tue, 10 Sep 2024 15:11:00 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.183]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4X36bP5DNNz4x9Px; Tue, 10 Sep 2024 15:10:57 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 0D.6F.19863.18160E66; Wed, 11 Sep 2024 00:10:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240910151057epcas5p3369c6257a6f169b4caa6dd59548b538c~z6qBz-63r3222232222epcas5p3U; Tue, 10 Sep 2024 15:10:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240910151057epsmtrp2126a8f34a06203ecb93029dde710d3e6~z6qBzAS1z0448904489epsmtrp22; Tue, 10 Sep 2024 15:10:57 +0000 (GMT) X-AuditID: b6c32a50-ef5fe70000004d97-53-66e061816a21 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 3B.DC.08964.08160E66; Wed, 11 Sep 2024 00:10:56 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240910151052epsmtip2a6272dcf0635487a8ae424134981622e~z6p98Iw6Q1662516625epsmtip2n; Tue, 10 Sep 2024 15:10:52 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jaegeuk@kernel.org, jlayton@kernel.org, chuck.lever@oracle.com, bvanassche@acm.org Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, gost.dev@samsung.com, vishak.g@samsung.com, javier.gonz@samsung.com, Nitesh Shetty , Kanchan Joshi Subject: [PATCH v5 4/5] sd: limit to use write life hints Date: Tue, 10 Sep 2024 20:31:59 +0530 Message-Id: <20240910150200.6589-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910150200.6589-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01TbTBcVxh2790vZlZvkXGy2pA7bSe02K3ddZig0kzdSTpTM2mnKdPqjb2s WXZ39gPRThCDRNJoUKlFmEZlWEQQ9TlpVraKNBLaJFTYKKU0hEXH+Op+SJt/z/vO85z3ed5z DgdzWWXxOAlyDa2SU4kEy4nR2uPt45tJmeL4+u/fgPrH+Sw437OMwOJn6xjceTyDwpEf21FY ozeisPRSFgqnrukweD2fA/8YM7PhenUtGxp3nrJggeEBArtH34RD30XAru4+BqyonmbDcw/b WPBq7zYKWzcqMNgwv8iAg1u9TDioK2O/404O/3qUHBy/ziCLC/pZ5PAvWrKp9iyLbK5KJzsr zSjZOZLBIpemRxnkhZZahLxTeZtNmpv2kU1TT9FIbpTsoJSmJLTKi5bHKiQJ8vgQ4uixmHdj RGK+wFcQBAMJLzmVRIcQh9+P9H0vIdESnPBKphK1llYkpVYT/qEHVQqthvaSKtSaEIJWShKV QqWfmkpSa+XxfnJaEyzg898WWYify6QmvYmhXHJKvdUoyUA2OHmIIwfgQlBXOMfIQ5w4LngX ArLySln2YhkBmfdvYvZiDQGnr+QynkuM5w27rG4E3N0xI/bCjIC17SGLhMNh4d7gXqHW2nfD L6Pgp3tGGwnDO1FQpJthWo9yxYPAtnEZtWIG/joYu7zCtIq5eCDY6ne3T/MEJUP/sK3YEYdg 5mqdjc7FXwZ9JVM2R5iFk3Wj1GYV4JccQb+uedfqYVA4cR6zY1cw19vCtmMeMC90s+xYBkyT pl3+l6Ct+QLTjsNAxuYjmx/MEuZah799ljP4amMKtbYBzgVnclzs7P1gvGB6V+kOnnxbxbRT SGDM3GtfzzkETA7Vsb9GPHUvJNC9kED3/7BKBKtFeLRSnRRPx4qUAl85nfLfxcYqkpoQ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K1oDg3PbfYsMAwL7Vcrzgxt7g0L10vOT93EyM4brU0dzBuX/VB7xAjEwfjIUYJDmYl Ed5+u3tpQrwpiZVVqUX58UWlOanFhxilOViUxHnFX/SmCAmkJ5akZqemFqQWwWSZODilGphS WebtPPDIx/VC/hKXm9J2S3aniYkq3Ps9TUjv+dJo8ZrLe/u/za3Iz2Fd/ugC51TN71qPlm3K 7l2ZqByuEhz+vTn9mfEV84RTax1figVHa52+L2/N+Pf034kbZztFZf+PPrd+o9zZj3vecDX5 WF/4fPhM516nKYYrXFPP7Z7K9erFhT1flyqbz+uT/R2n/2LXMnVgOs6yX/N/8syFB2+vfKOQ dff1uvVfhBdGLjdbnFUS8OqUiPFBTWcdhtKL65bNsJ+Qb7Dk7J1TYTyBNdw76hJ2zWhzjDc0 0n/WZD1z+8EIjZmzDzmzVu19ErfbzZ+viqP1pkSuU87fg6nZX/4Ivlc1OmRSvXDZ0W2Ma9c8 UGIpzkg01GIuKk4EAGXB181KAwAA X-CMS-MailID: 20240910151057epcas5p3369c6257a6f169b4caa6dd59548b538c X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240910151057epcas5p3369c6257a6f169b4caa6dd59548b538c References: <20240910150200.6589-1-joshi.k@samsung.com> From: Nitesh Shetty The incoming hint value maybe either lifetime hint or placement hint. Make SCSI interpret only temperature-based write lifetime hints. Signed-off-by: Nitesh Shetty Signed-off-by: Kanchan Joshi --- drivers/scsi/sd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index dad3991397cf..82bd4b07314e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1191,8 +1191,8 @@ static u8 sd_group_number(struct scsi_cmnd *cmd) if (!sdkp->rscs) return 0; - return min3((u32)rq->write_hint, (u32)sdkp->permanent_stream_count, - 0x3fu); + return min3((u32)WRITE_LIFETIME_HINT(rq->write_hint), + (u32)sdkp->permanent_stream_count, 0x3fu); } static blk_status_t sd_setup_rw32_cmnd(struct scsi_cmnd *cmd, bool write, @@ -1390,7 +1390,8 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) ret = sd_setup_rw16_cmnd(cmd, write, lba, nr_blocks, protect | fua, dld); } else if ((nr_blocks > 0xff) || (lba > 0x1fffff) || - sdp->use_10_for_rw || protect || rq->write_hint) { + sdp->use_10_for_rw || protect || + WRITE_LIFETIME_HINT(rq->write_hint)) { ret = sd_setup_rw10_cmnd(cmd, write, lba, nr_blocks, protect | fua); } else { From patchwork Tue Sep 10 15:02:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 827288 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C793C19C56E for ; Tue, 10 Sep 2024 15:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981068; cv=none; b=URoxHS4nHgeMHtK/R0rCX9+aIOm7lUO5Xgz89PJHNv7dgzRv2zUf0BA7mwdN8sylzMHwn0fDGHm9I6cArC0u04wvFZhqXRf7K9lXrxgd/VNyG4+/iIgt+DascBDAA/YgwDhm2EjpSojJkZkIQGPWpWrA6UOy8/yeEQ/AiwMwuJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725981068; c=relaxed/simple; bh=xa39tV+/J/Ijkix2WXsbZB4TNXSi5foj4O86+UeK/Dg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=smcEIKdfvYL4RqxI3atd1EUqXFZmqQsRR3/HGIwGdN7FcW1YIGHWiYNVaoyyKDq+RlPzR3vlG0JRwxcpFuM2kZE97pv+BSpEslAg5dnbEQasaA7VjsMD5+5eJUys1QKHiEEiXg01rJVmZJCH6bmrhbzhtR8crNo1poNxOiDVEgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=tEH0LVYE; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="tEH0LVYE" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240910151104epoutp047b815334ef72426e3c251dedd7f786cc~z6qIglwno1896418964epoutp04x for ; Tue, 10 Sep 2024 15:11:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240910151104epoutp047b815334ef72426e3c251dedd7f786cc~z6qIglwno1896418964epoutp04x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1725981064; bh=Cx4od5b8pH/z+90Z4fWrUdEipftlwMkCWoeWtxKWTrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEH0LVYEDUWgmJbiZLMkrGc8noYOXYlKcW6VUF+ihRJmpS92mB42Baz5VMtH+sq6V 6Hk8qPBF5hB/+XMAypQ5kvt8jQJiwObv7oX8xmxOh938KrIc8KhtX/uaqUv6+XkJDo ED7ZSlQkZk4H3mLA5Bzd+RtmcwI/wWV3MvE+hnNU= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240910151103epcas5p3253379b3a38eaea3aed189624bd0c861~z6qH6ZA8j0202102021epcas5p3o; Tue, 10 Sep 2024 15:11:03 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.178]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4X36bV3Bbhz4x9Pp; Tue, 10 Sep 2024 15:11:02 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2F.86.08855.68160E66; Wed, 11 Sep 2024 00:11:02 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240910151101epcas5p1c4e90f7334125fc49106d58d43cffcec~z6qGHmfzO1123511235epcas5p1F; Tue, 10 Sep 2024 15:11:01 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240910151101epsmtrp2c76da231088379ef89540de084989473~z6qGGk5730449204492epsmtrp2y; Tue, 10 Sep 2024 15:11:01 +0000 (GMT) X-AuditID: b6c32a44-107ff70000002297-0b-66e06186e7d6 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 89.F3.19367.58160E66; Wed, 11 Sep 2024 00:11:01 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240910151057epsmtip2777beeea22e07b64173647c11eb57f55~z6qB_xFoG1829618296epsmtip2D; Tue, 10 Sep 2024 15:10:57 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com, brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, jaegeuk@kernel.org, jlayton@kernel.org, chuck.lever@oracle.com, bvanassche@acm.org Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, gost.dev@samsung.com, vishak.g@samsung.com, javier.gonz@samsung.com, Kanchan Joshi , Nitesh Shetty , Hui Qi Subject: [PATCH v5 5/5] nvme: enable FDP support Date: Tue, 10 Sep 2024 20:32:00 +0530 Message-Id: <20240910150200.6589-6-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910150200.6589-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01Ta1BUZRie75zds2ephcPCygem0jZlYMCuwfrhgDaJdcqmwcphuhhsu4fL LHt220saUTJeQKVEoRCWBMZB2BACuQmsEGJEQIIhI5cSQRYMGAJZGsdQaNlF89/zPt/zvO88 7zcviQv/JXzIBNbA6Fh5ophw4dRd8fMLSJWPxEo6+13R+ZsZBJq+Mg9Q9tx9HC3fvIOhwZYG DP1wvg1DDcXlPJR3+hCGrBUmHF3IINHYnzYeul9cykNtyzMEymy9AVDT0CbUe/Z1dKmpg4MK isd5KL2/nkAl7UsYqlsswNGP07Mc1POwnYt6TN/zXoH09b5ddM/wBQ6dndlJ0NevGumq0mME XV10gLYU2jDaMphC0HfHhzj0iZpSQP9W+DOPtlWtp6usM1ik4ANVWDwjVzI6X4ZVaJQJbFy4 eNe70TuiQ2QSaYA0FG0R+7JyNRMujngrMuC1hER7erHvZ/JEo52KlOv14qBtYTqN0cD4xmv0 hnAxo1UmaoO1gXq5Wm9k4wJZxrBVKpFsDrELY1Txh2t8tZMh+++llvNSQM+m44BPQioYfptj xY8DF1JIWQAc6F8mnMU8gD91j4DHha27DjyyXKxN4zgfGgBs6qhaVdkANJtT7c1IkqD84LUs 4wrvSeVj8JdrbQ4RTg1h0DJpdrTyoCQws2SYt4I51PO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mZJalFunbJXBltGxRKHhpWvG9bS17A+N57S5G Tg4JAROJ7VvbWboYuTiEBLYzSrxoe8oKkRCXaL72gx3CFpZY+e85O0TRR0aJ6WtWM3cxcnCw CWhKXJhcClIjIrCOSWLFNB+QGmaBZ0wSd2dvYQJJCAsYSExafg9sEIuAqsTye4/AbF4Bc4mD Ez4xQiyQl5h56TtYnFPAQuL58jVgvUJANR/6F7BC1AtKnJz5hAXEZgaqb946m3kCo8AsJKlZ SFILGJlWMYqmFhTnpucmFxjqFSfmFpfmpesl5+duYgTHrlbQDsZl6//qHWJk4mA8xCjBwawk wttvdy9NiDclsbIqtSg/vqg0J7X4EKM0B4uSOK9yTmeKkEB6YklqdmpqQWoRTJaJg1OqgSnz q6KXTX7ejmP+JmueR4oZHPr28srUS75eM3NlGZbUTGljT0psjJ5a+bOwTjGdszZF/fSL5v8/ 13ep5Srlrvjf0Hah8YZmYo5EY7h2SahwSMflpHefd/U/ObZZ72NC4l7G6oPuOuYC725J2u8r fsJbbb9XTTj007m2SvMznvNaGnvC6nbN2li7Q9bR2ezNCwG3Q1fmfdqVoOp+f86cIkU31VtS ORJHmj7bOHj1nJ558/XGnGkXf+q1rEr8vNzo8vWJIb1M7fe2uOsZXjuycONGmVOXQrIKJFk9 V97eezH2e0kMq9T02p6Xi1ov7jPJzZ/yIEaz0Tz++srlH7vT7jalHhOQSr526amAae9kCSWW 4oxEQy3mouJEAD1N3XNMAwAA X-CMS-MailID: 20240910151101epcas5p1c4e90f7334125fc49106d58d43cffcec X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240910151101epcas5p1c4e90f7334125fc49106d58d43cffcec References: <20240910150200.6589-1-joshi.k@samsung.com> Flexible Data Placement (FDP), as ratified in TP 4146a, allows the host to control the placement of logical blocks so as to reduce the SSD WAF. Userspace can send the data placement information using the write hints. Fetch the placement-identifiers if the device supports FDP. The incoming placement hint is mapped to a placement-identifier, which in turn is set in the DSPEC field of the write command. Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Hui Qi Acked-by: Keith Busch --- drivers/nvme/host/core.c | 81 ++++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 4 ++ include/linux/nvme.h | 19 ++++++++++ 3 files changed, 104 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index cb846521a77f..5fee63dbb80b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -44,6 +44,20 @@ struct nvme_ns_info { bool is_removed; }; +struct nvme_fdp_ruh_status_desc { + u16 pid; + u16 ruhid; + u32 earutr; + u64 ruamw; + u8 rsvd16[16]; +}; + +struct nvme_fdp_ruh_status { + u8 rsvd0[14]; + __le16 nruhsd; + struct nvme_fdp_ruh_status_desc ruhsd[]; +}; + unsigned int admin_timeout = 60; module_param(admin_timeout, uint, 0644); MODULE_PARM_DESC(admin_timeout, "timeout in seconds for admin commands"); @@ -657,6 +671,7 @@ static void nvme_free_ns_head(struct kref *ref) ida_free(&head->subsys->ns_ida, head->instance); cleanup_srcu_struct(&head->srcu); nvme_put_subsystem(head->subsys); + kfree(head->plids); kfree(head); } @@ -959,6 +974,17 @@ static bool nvme_valid_atomic_write(struct request *req) return true; } +static inline void nvme_assign_placement_id(struct nvme_ns *ns, + struct request *req, + struct nvme_command *cmd) +{ + u8 h = umin(ns->head->nr_plids - 1, + WRITE_PLACEMENT_HINT(req->write_hint)); + + cmd->rw.control |= cpu_to_le16(NVME_RW_DTYPE_DPLCMT); + cmd->rw.dsmgmt |= cpu_to_le32(ns->head->plids[h] << 16); +} + static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, struct request *req, struct nvme_command *cmnd, enum nvme_opcode op) @@ -1078,6 +1104,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req) break; case REQ_OP_WRITE: ret = nvme_setup_rw(ns, req, cmd, nvme_cmd_write); + if (!ret && ns->head->nr_plids) + nvme_assign_placement_id(ns, req, cmd); break; case REQ_OP_ZONE_APPEND: ret = nvme_setup_rw(ns, req, cmd, nvme_cmd_zone_append); @@ -2114,6 +2142,52 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns, return ret; } +static int nvme_fetch_fdp_plids(struct nvme_ns *ns, u32 nsid) +{ + struct nvme_command c = {}; + struct nvme_fdp_ruh_status *ruhs; + struct nvme_fdp_ruh_status_desc *ruhsd; + int size, ret, i; + +refetch_plids: + size = struct_size(ruhs, ruhsd, ns->head->nr_plids); + ruhs = kzalloc(size, GFP_KERNEL); + if (!ruhs) + return -ENOMEM; + + c.imr.opcode = nvme_cmd_io_mgmt_recv; + c.imr.nsid = cpu_to_le32(nsid); + c.imr.mo = 0x1; + c.imr.numd = cpu_to_le32((size >> 2) - 1); + + ret = nvme_submit_sync_cmd(ns->queue, &c, ruhs, size); + if (ret) + goto out; + + if (!ns->head->nr_plids) { + ns->head->nr_plids = le16_to_cpu(ruhs->nruhsd); + ns->head->nr_plids = + min_t(u16, ns->head->nr_plids, NVME_MAX_PLIDS); + + if (!ns->head->nr_plids) + goto out; + + kfree(ruhs); + goto refetch_plids; + } + ns->head->plids = kzalloc(ns->head->nr_plids * sizeof(u16), GFP_KERNEL); + if (!ns->head->plids) + return -ENOMEM; + + for (i = 0; i < ns->head->nr_plids; i++) { + ruhsd = &ruhs->ruhsd[i]; + ns->head->plids[i] = le16_to_cpu(ruhsd->pid); + } +out: + kfree(ruhs); + return ret; +} + static int nvme_update_ns_info_block(struct nvme_ns *ns, struct nvme_ns_info *info) { @@ -2205,6 +2279,13 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, if (ret && !nvme_first_scan(ns->disk)) goto out; } + if (ns->ctrl->ctratt & NVME_CTRL_ATTR_FDPS) { + ret = nvme_fetch_fdp_plids(ns, info->nsid); + if (ret) + dev_warn(ns->ctrl->device, + "FDP failure status:0x%x\n", ret); + } + ret = 0; out: diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index c717c051c6fd..e7fe39598507 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -449,6 +449,8 @@ struct nvme_ns_ids { u8 csi; }; +#define NVME_MAX_PLIDS (MAX_PLACEMENT_HINT_VAL + 1) + /* * Anchor structure for namespaces. There is one for each namespace in a * NVMe subsystem that any of our controllers can see, and the namespace @@ -470,6 +472,8 @@ struct nvme_ns_head { struct kref ref; bool shared; bool passthru_err_log_enabled; + u16 nr_plids; + u16 *plids; struct nvme_effects_log *effects; u64 nuse; unsigned ns_id; diff --git a/include/linux/nvme.h b/include/linux/nvme.h index b58d9405d65e..a954eaee5b0f 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -275,6 +275,7 @@ enum nvme_ctrl_attr { NVME_CTRL_ATTR_HID_128_BIT = (1 << 0), NVME_CTRL_ATTR_TBKAS = (1 << 6), NVME_CTRL_ATTR_ELBAS = (1 << 15), + NVME_CTRL_ATTR_FDPS = (1 << 19), }; struct nvme_id_ctrl { @@ -843,6 +844,7 @@ enum nvme_opcode { nvme_cmd_resv_register = 0x0d, nvme_cmd_resv_report = 0x0e, nvme_cmd_resv_acquire = 0x11, + nvme_cmd_io_mgmt_recv = 0x12, nvme_cmd_resv_release = 0x15, nvme_cmd_zone_mgmt_send = 0x79, nvme_cmd_zone_mgmt_recv = 0x7a, @@ -864,6 +866,7 @@ enum nvme_opcode { nvme_opcode_name(nvme_cmd_resv_register), \ nvme_opcode_name(nvme_cmd_resv_report), \ nvme_opcode_name(nvme_cmd_resv_acquire), \ + nvme_opcode_name(nvme_cmd_io_mgmt_recv), \ nvme_opcode_name(nvme_cmd_resv_release), \ nvme_opcode_name(nvme_cmd_zone_mgmt_send), \ nvme_opcode_name(nvme_cmd_zone_mgmt_recv), \ @@ -1015,6 +1018,7 @@ enum { NVME_RW_PRINFO_PRCHK_GUARD = 1 << 12, NVME_RW_PRINFO_PRACT = 1 << 13, NVME_RW_DTYPE_STREAMS = 1 << 4, + NVME_RW_DTYPE_DPLCMT = 2 << 4, NVME_WZ_DEAC = 1 << 9, }; @@ -1102,6 +1106,20 @@ struct nvme_zone_mgmt_recv_cmd { __le32 cdw14[2]; }; +struct nvme_io_mgmt_recv_cmd { + __u8 opcode; + __u8 flags; + __u16 command_id; + __le32 nsid; + __le64 rsvd2[2]; + union nvme_data_ptr dptr; + __u8 mo; + __u8 rsvd11; + __u16 mos; + __le32 numd; + __le32 cdw12[4]; +}; + enum { NVME_ZRA_ZONE_REPORT = 0, NVME_ZRASF_ZONE_REPORT_ALL = 0, @@ -1822,6 +1840,7 @@ struct nvme_command { struct nvmf_auth_receive_command auth_receive; struct nvme_dbbuf dbbuf; struct nvme_directive_cmd directive; + struct nvme_io_mgmt_recv_cmd imr; }; };