From patchwork Mon Aug 26 17:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13778233 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 9FB9918D64D for ; Mon, 26 Aug 2024 17:14:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692461; cv=none; b=iCL4JLBa4ezgNpTsfk128sFwdgTZVLTq26Tk90/8edgpJfUnBkc4B8RUl/WZiKjw6na5CXdGIRCM+I/4pPVqrFVndG37V+xSc3FzDDsV416UEGWVHBpWUM5SdYXfNqGFSSkD6Bk8g3PWTwg4LRpCOk0UPwnByMDww0Xh3kbCXRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692461; c=relaxed/simple; bh=vlNkw3AENHtkH375pk1CuSNNuSUaFix2ofNNRkWPJkQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=vA/sBvemId/zZIMrUvrMmTGZSGzdKwAlmyFkuBXfjrAyGTdCUI8ZYR8Ahi60IxlkQSb31TBY43udk8HUORGCgW5A20stLdMwMyjDzEu3nwPZFyYv1Rk9jFpT3QlaVWnyod3RzsZvrJpjd1jm9br/RQ/3vIMh3iEtpDxqKNzdAos= 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=Ney4vvAr; arc=none smtp.client-ip=203.254.224.24 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="Ney4vvAr" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240826171417epoutp01e1b0d7ea55b5ea2d112746149ac7cf87~vVqcDb4EY0190901909epoutp01k for ; Mon, 26 Aug 2024 17:14:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240826171417epoutp01e1b0d7ea55b5ea2d112746149ac7cf87~vVqcDb4EY0190901909epoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724692457; bh=n7zhETWk1+f1X9Po3Riik9xlyIuyCM60BVQS3x/oaSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ney4vvArH7DzdwakCU1vjnI0o18elhCr95kI0PpEZz0DNBXRRpbN4tDpxEonv0VHc lZfeq5O4pBduUsEfG4Vij7hwVLa9a2n8MZHGfZN/XlnpwtdSREwlOi3rrtypJoXw6c IPqUU0tRx2xlIWljXVZL6Zqi1vSnXW5kLhK9EuUo= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240826171416epcas5p387c52a2f89722239f0e46e82d9da5f2c~vVqbY5mM20591005910epcas5p3g; Mon, 26 Aug 2024 17:14:16 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.180]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Wsy2b24qNz4x9Pr; Mon, 26 Aug 2024 17:14:15 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A9.A0.09640.7E7BCC66; Tue, 27 Aug 2024 02:14:15 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240826171413epcas5p3f62c2cc57b50d6df8fa66af5fe5996c5~vVqYcHYhY2945329453epcas5p3n; Mon, 26 Aug 2024 17:14:13 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240826171413epsmtrp11fd9c5290d075794afe2600dcc86895a~vVqYbPfbL0078300783epsmtrp1B; Mon, 26 Aug 2024 17:14:13 +0000 (GMT) X-AuditID: b6c32a49-aabb8700000025a8-9a-66ccb7e77fe6 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 6C.51.19367.5E7BCC66; Tue, 27 Aug 2024 02:14:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240826171409epsmtip20e565ee1cbc1d1a5846d9a8ded949674~vVqU042770841308413epsmtip2M; Mon, 26 Aug 2024 17:14:09 +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, 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 v4 1/5] fs, block: refactor enum rw_hint Date: Mon, 26 Aug 2024 22:36:02 +0530 Message-Id: <20240826170606.255718-2-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826170606.255718-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.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OaczRUggPbEkNTs1tSC1CCbLxMEp1cBkmPY2Mi/R9G8gR1Bh95Ms904Nlp6o 9NMb/yuedz2UvvJAxdXJtgHKaUUayWb+6/KdL+8pelEcOzfz11+BIns//ZniNVbrF7C4cApu Zp68p+N6bYzc5+1rnjQw9V93XRqx05DP09LBgodzZqBE5O/Hdo6Bmj33sh8ebVTvanPqnTUx WYE14+lKq9O7qnc8Dz+oJMf+1+C+ndH5EK47M6xyOD2+9yYZrbwm/qfoSuqV1Cffv2w6uinV Jv1J+T6mmOi3HMLTttsLtH10yC95LXLRv+7j3y8/v6mnvLOt0VnGJ7rqTso56VWFK2I/MPR+ zZ4hkL7ioZ/CpIiKBywKC8Kl+F4oMwX+tvSeaXs4V4mlOCPRUIu5qDgRAE0F3PY4AwAA X-CMS-MailID: 20240826171413epcas5p3f62c2cc57b50d6df8fa66af5fe5996c5 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240826171413epcas5p3f62c2cc57b50d6df8fa66af5fe5996c5 References: <20240826170606.255718-1-joshi.k@samsung.com> Rename enum rw_hint to rw_life_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 | 4 ++-- fs/f2fs/segment.c | 4 ++-- include/linux/blk-mq.h | 2 +- include/linux/blk_types.h | 2 +- include/linux/fs.h | 2 +- include/linux/rw_hint.h | 9 ++------- 7 files changed, 11 insertions(+), 16 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..b3022dc94a1f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3756,8 +3756,8 @@ 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_life_hint hint); +enum rw_life_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..794050f4cdbf 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3381,7 +3381,7 @@ 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_life_hint hint) { if (F2FS_OPTION(sbi).active_logs == 2) return CURSEG_HOT_DATA; @@ -3425,7 +3425,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_life_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..e17fd9fa65d4 100644 --- a/include/linux/rw_hint.h +++ b/include/linux/rw_hint.h @@ -7,18 +7,13 @@ #include /* Block storage write lifetime hint values. */ -enum rw_hint { +enum rw_life_hint { WRITE_LIFE_NOT_SET = RWH_WRITE_LIFE_NOT_SET, WRITE_LIFE_NONE = RWH_WRITE_LIFE_NONE, WRITE_LIFE_SHORT = RWH_WRITE_LIFE_SHORT, WRITE_LIFE_MEDIUM = RWH_WRITE_LIFE_MEDIUM, WRITE_LIFE_LONG = RWH_WRITE_LIFE_LONG, WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, -} __packed; - -/* Sparse ignores __packed annotations on enums, hence the #ifndef below. */ -#ifndef __CHECKER__ -static_assert(sizeof(enum rw_hint) == 1); -#endif +}; #endif /* _LINUX_RW_HINT_H */ From patchwork Mon Aug 26 17:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13778234 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 A9CD518D64D for ; Mon, 26 Aug 2024 17:14:22 +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=1724692464; cv=none; b=A/f8Tdwyd5USbrXg9ABVyx092ckUWSPO+9ml0AWJyAmDaduMHWt2ZRAbM5sjeE7/1soib9bCzh/8DTachXTVG7sdUEp/iSDt7kz9DdUuGdoeYt6nuK6RZutEpx7V9FGqjQK4bI/MXCTOfZfK6pkBDmzPeKeUCQhZ7NOLcfIMvmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692464; c=relaxed/simple; bh=Qs+0/eghBwmI0+lDjMQ599piAQB0g7zovPudUM+h4To=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=RHuzfAXBA2Wan5WN5Vb1KgP/KcrOQ1pdWL8hCZdHHeGmHKErDyzkmoQh7P0Mt5FMe1kmpHeaNdz/14QegBddPd4xJbLAg8JXeOubyIbhftlSqsQuUv5xL2fLcvCEcSdQRegVIBfmqjYuRQyeJbzfI/k0j/nL3CkEZDWA2DlzfYE= 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=WFfY1jcw; 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="WFfY1jcw" Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240826171420epoutp02ba28bdd815a072e1db7d8136edb609d2~vVqe9DcGK2068320683epoutp02n for ; Mon, 26 Aug 2024 17:14:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240826171420epoutp02ba28bdd815a072e1db7d8136edb609d2~vVqe9DcGK2068320683epoutp02n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724692460; bh=dvmnXluL763m/k/i9q5rrEgvQ+XYswDEKR5fFJwq0zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFfY1jcwoJQ7QQ43GdoomZSnARi7RvDtwJOeywCslMObHyPHu/+S7VeWrF4zzNEKN zB6FNbCioR14iuWC+EXawfBAf97MIuUSdlftEMo2Mc0r6UBrkhMcC6npg3RokJbnsB f5+Rr5WaasQVzwCfYYfMzq9tJuLp2atyTlSPskp0= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240826171419epcas5p23cc7ff5eeadbd876a1ae23a70d292612~vVqeOcWQv0605906059epcas5p2q; Mon, 26 Aug 2024 17:14:19 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.178]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Wsy2f1scRz4x9Pt; Mon, 26 Aug 2024 17:14:18 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id 09.67.19863.AE7BCC66; Tue, 27 Aug 2024 02:14:18 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240826171417epcas5p1c6dbe318c43324116647dae2129b7eb3~vVqcNuU9j0392603926epcas5p1p; Mon, 26 Aug 2024 17:14:17 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240826171417epsmtrp2d498a352e437e2c14cc2c22ecf314eff~vVqcMys6o3048030480epsmtrp2i; Mon, 26 Aug 2024 17:14:17 +0000 (GMT) X-AuditID: b6c32a50-ef5fe70000004d97-80-66ccb7ea69f1 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5C.3E.08964.9E7BCC66; Tue, 27 Aug 2024 02:14:17 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240826171413epsmtip2407f4dc023aef06fcca161d1f824ce43~vVqYlY3Pe0834608346epsmtip2O; Mon, 26 Aug 2024 17:14:13 +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, 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 v4 2/5] fcntl: rename rw_hint_* to rw_life_hint_* Date: Mon, 26 Aug 2024 22:36:03 +0530 Message-Id: <20240826170606.255718-3-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826170606.255718-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01Te0xTVxjfubfcFmPNHS9PukzwRk2AgXSWejCUjUHmTWBJo4uZ4gKFXgqh tLWPbSK6GpxxRWBW8IFusNkVLZFnN1AsMBgqhMVN2HiMlwxkg2F5SnAIa2nd/O/3/b7f933n 951zOLjXnwSPk67QMmqFRE4RG1jftwYGhUzWdaaGzS6zUflgAYGmWucAujCzjKO1wQkM9TXf wtCN8jYMXbmYg6GxymIcVRdw0B8D82y0bLawUdvaNIGMLb8BZOsPRg+/2Yvu2NpZqMQ8zka5 PfUEKru3iqGKKTsLPSi+yn7bl+7qjqMfDFWz6AvGDoLu+klH11g+J+ha06d0Q+k8Rjf06Ql6 dryfRedbLYDuLP2RTc/XbBFvPJQRmcZIpIw6gFGkKKXpCpmIitufGJMYLgzjh/Aj0G4qQCHJ ZERUbLw45N10ucMpFfCRRK5zUGKJRkPtjIpUK3VaJiBNqdGKKEYllasEqlCNJFOjU8hCFYx2 Dz8s7M1whzApI+3W7R/YqifkJ/3TvYQedHMNwJMDSQGsHjYAA9jA8SLvANjzuJFwBXMArpqL 2K7gKYALPSXEi5LFbquHK2ED8Jepk27VPID9dT2ODIdDkIHw5/M6J+9D5mCw+uaz9b44acTg 7MhNwinyJqNhlUno7Moit8NnV+0sJ+aSEdCWOwdc0/zh5YdLbCf2JPfAtRk726V5FbZfHlvX 4w5NzndXcGd/SK5x4JmKAbarOBaW5i+6j+0NJ+9Z3TwPzj+xufkMODI6wnLhbFhfm+/hwm9B /UrvuhncYaby9k7XrE0w758xzElDkgvPnPZyqbfCIeO4u3IzfHTJ5MY0LD9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3gP tctSYuWZ5ewQ9YISJ2c+AetlBqpv3jqbeQKjwCwkqVlIUgsYmVYxSqYWFOem5xYbFhjmpZbr FSfmFpfmpesl5+duYgRHppbmDsbtqz7oHWJk4mA8xCjBwawkwit3+WSaEG9KYmVValF+fFFp TmrxIUZpDhYlcV7xF70pQgLpiSWp2ampBalFMFkmDk6pBqaI361bzdYefGvotaUs0pcxS1Zz X6zrROkJOuGZtVszXeapXojrEYj2upp1teTdynKVzLKYa3o/lrAcedEWaHdJ/HLAJ59nXCmz xTYZP3345lLWgsVzXp8Snez4WvDx72/vtjTfEJPT+bdoZ+rjhwwrg/fM85hv90L0cs2NT34K pfq8em++RTv+vs8Z7H45UtnC6cPnXi+2dqfP2iekMu0X2/dfzUxq2CvvMCVLeT1HtNXVlze4 AiSyF4i6/NucvXyB5Ro5Y5EZ0tOVXL0X+rlG2h6eF2djdiDoRmLDvqrKdfucV6bu9FW7fKp6 +dPqHpGia0t+W374HKJ1w2ndooVXRc/fPpe9/E+seVRvpLsSS3FGoqEWc1FxIgAB0w2bOwMA AA== X-CMS-MailID: 20240826171417epcas5p1c6dbe318c43324116647dae2129b7eb3 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240826171417epcas5p1c6dbe318c43324116647dae2129b7eb3 References: <20240826170606.255718-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..46cf08f67278 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_life_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_life_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_life_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_life_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_life_hint(filp, cmd, arg); break; case F_SET_RW_HINT: - err = fcntl_set_rw_hint(filp, cmd, arg); + err = fcntl_set_rw_life_hint(filp, cmd, arg); break; default: break; From patchwork Mon Aug 26 17:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13778235 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 5C68E19409E for ; Mon, 26 Aug 2024 17:14:27 +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=1724692469; cv=none; b=MhVxov/uLPRKTt9vkzbkzMDcQZAzAb2iaisH1+tzfGn7LNJ3uumX5wQF88HzaV/iDe94jurNztBaT91RY8mZzUUNwjuNFiJWRNJo62WpOG9FDdP46U/sr7lu7A7IwtNbfJP25LkMHSvj6sAlTRIP1gRslzkOCtwSyAnQKqxYStU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692469; c=relaxed/simple; bh=AUoypyHv0/bPzK3CdgiN0SLBCA9RpFvaVPOxWvIMzwA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=WzCj2gSfccWVRDOxCja0+6x/o6vCUiTppn16IiyClSSZQFT4mjdBzmqVs9pEE4aDWkJgYJfOT3XkfSvy4/61OlS0+D65jBRQMpdiYzObl0nwqs1LA8cmnIdHYEGZVQkedxd0mvJ8L9zHvRRbYjLIWSISqlmwOz3eMGuju1LsjMQ= 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=NRsw+253; 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="NRsw+253" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240826171425epoutp04e96c18bb617a3ab5c8841a6b2793af7d~vVqjKKl_H0762207622epoutp04I for ; Mon, 26 Aug 2024 17:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240826171425epoutp04e96c18bb617a3ab5c8841a6b2793af7d~vVqjKKl_H0762207622epoutp04I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724692465; bh=QlraUz7mWC5TpMsZSNLhl1IWSfYiPF9JCt4MhSxeqoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRsw+253QMVRB0m/LvwfxTc8ZOEb1ce7akJ5B0DUuK76F3H6yC4GTBvpABG7v54Gt hB2+RIsvqxj/7QaHKwydtBjUhafZtJvyz2ZoFgRunRun0n6FITtrGlHv/395IfdG8/ yfIYeAUa9QotfgpKG3ZQlAS/ed9DnMptaUuaqTWk= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240826171424epcas5p19fd9d13160492dad59fc62ede3ae8b40~vVqiicTjz0279002790epcas5p1B; Mon, 26 Aug 2024 17:14:24 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.174]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Wsy2k6F6Dz4x9Pp; Mon, 26 Aug 2024 17:14:22 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2B.A0.09640.EE7BCC66; Tue, 27 Aug 2024 02:14:22 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240826171422epcas5p2fa8f07dfee9395745f1833a17fd89ae0~vVqgJJQK20606606066epcas5p2b; Mon, 26 Aug 2024 17:14:22 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240826171422epsmtrp2c1f602264c43742010b82095caff9901~vVqgIV8sL3048030480epsmtrp2k; Mon, 26 Aug 2024 17:14:22 +0000 (GMT) X-AuditID: b6c32a49-a57ff700000025a8-a3-66ccb7eef81b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 2E.51.19367.DE7BCC66; Tue, 27 Aug 2024 02:14:21 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240826171417epsmtip2300cf238d11e054982f5ca67e497e4ab~vVqcWaisS0040200402epsmtip2e; Mon, 26 Aug 2024 17:14:17 +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, 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 v4 3/5] fcntl: add F_{SET/GET}_RW_HINT_EX Date: Mon, 26 Aug 2024 22:36:04 +0530 Message-Id: <20240826170606.255718-4-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826170606.255718-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDJsWRmVeSWpSXmKPExsWy7bCmpu677WfSDL7/0rRYfbefzeL14U+M FtM+/GS2+H/3OZPFzQM7mSxWrj7KZDF7ejOTxZP1s5gtNvZzWDy+85nd4ueyVewWR/+/ZbOY dOgao8XeW9oWlxa5W+zZe5LFYv6yp+wW3dd3sFksP/6PyWLb7/nMFutev2exOD9rDruDmMfl K94e5+9tZPGYNukUm8fls6Uem1Z1snlsXlLvsXvBZyaP3Tcb2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qlxfrXSUoc76ltC10Ve3im5JMkjoiox/dWt6AmH a0V1NQQvx2U47XxZlzOL5/WRGVcqXWZ9brD63/qOK2jtCSWW4oxEQy3mouJEAD2lDs0+AwAA X-CMS-MailID: 20240826171422epcas5p2fa8f07dfee9395745f1833a17fd89ae0 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240826171422epcas5p2fa8f07dfee9395745f1833a17fd89ae0 References: <20240826170606.255718-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 life hint (TYPE_RW_LIFE_HINT) or placement hint (TYPE_RW_PLACEMENT_HINT). The interface allows to add more hint types in future. Valid values for life hints are same as enforced by existing fcntl(F_SET_RW_HINT). Valid values for placement hints are between 0 to 127, both inclusive. The inode retains either the life 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 life 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 46cf08f67278..d82fd4142104 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -291,6 +291,14 @@ static bool rw_life_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_life_hint(struct file *file, unsigned int cmd, unsigned long arg) { @@ -327,6 +335,59 @@ static long fcntl_set_rw_life_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_LIFE_HINT: + if (!rw_life_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_life_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 e17fd9fa65d4..611c51d23d96 100644 --- a/include/linux/rw_hint.h +++ b/include/linux/rw_hint.h @@ -16,4 +16,17 @@ enum rw_life_hint { WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, }; +#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_LIFE_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_LIFE_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 #endif /* _LINUX_RW_HINT_H */ diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index c0bcc185fa48..dfe77fa86776 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_LIFE_HINT, + 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 Mon Aug 26 17:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13778236 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 17E71198A36 for ; Mon, 26 Aug 2024 17:14:31 +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=1724692473; cv=none; b=W/w/vewnBEvC9hNrClbFanDBOReORlVcTSKCA23Zhjz+bwnj4Tt5b5nw/ljpCX6/sdf3bNJeoPb9OoCj061g4CZr5NamnfzfGf1MUV+WDNN7pBmCV9PNsZpe5KkVI3V4a3ND0eZeBpzNA59MKvxqe9vU/ohz7hgUt9YCUp4joVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692473; c=relaxed/simple; bh=tWd5IIy35vE30hYu41t/Mbu9amvaqfDTedWn194Fx2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=bh/I9ITbrCUyJzKX/wqyHGXTTzuR87gKjI0ZMdB0W+YQ4QX4VZxbwudS3niCFkyzNWB0filxrSJB/1LrgZyERemSAeNuJUsuB8qWWq809tIpJQrZkV0ILyd0Q+TSxDeb38r7YiGzWYF9qW5FmL+WqPD/K20YxO7KQ3v9Opphtwk= 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=aHNL1THi; 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="aHNL1THi" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240826171430epoutp0290c3f7c29c2de5d621f8b1a90b47a2f0~vVqn1lh4P2048020480epoutp021 for ; Mon, 26 Aug 2024 17:14:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240826171430epoutp0290c3f7c29c2de5d621f8b1a90b47a2f0~vVqn1lh4P2048020480epoutp021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724692470; bh=5tUKFADzd7xUVDEaIuNQBV6ClteUtrL2aFLyNyXedxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHNL1THiEHhEmCRokdU8knTuvgsSymAyuhlTlxo5pnMmOJ9QY5GJqy5xd8NjKrmgn KtBE6HF40PRjV5pMfG0rW5sqYneCfXRHF+F+KiZVSBS/OeqLDsiro0OHFglZuySsI9 GkfJEaG6hifEQRg6/nW1tdlTMPRTmA3NT351UUDA= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20240826171429epcas5p3d316437e37abe737b9cf1feb46a0bb13~vVqm84GMM2945329453epcas5p33; Mon, 26 Aug 2024 17:14:29 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.175]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Wsy2q4HHZz4x9Pq; Mon, 26 Aug 2024 17:14:27 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5D.A0.09640.3F7BCC66; Tue, 27 Aug 2024 02:14:27 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240826171426epcas5p13c5ffabd6a05ee357bf4e9f78bc5de44~vVqkF41jA0279002790epcas5p1G; Mon, 26 Aug 2024 17:14:26 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240826171426epsmtrp1c1c4ac8931df3d1325ad85cb6dd79fd8~vVqkE3uYz0078300783epsmtrp1H; Mon, 26 Aug 2024 17:14:26 +0000 (GMT) X-AuditID: b6c32a49-a57ff700000025a8-ad-66ccb7f3091c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F7.B2.07567.1F7BCC66; Tue, 27 Aug 2024 02:14:26 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240826171422epsmtip2e4bb622f4f1ead189d76183395aa4693~vVqgSFzYe0841308413epsmtip2O; Mon, 26 Aug 2024 17:14:21 +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, 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 v4 4/5] sd: limit to use write life hints Date: Mon, 26 Aug 2024 22:36:05 +0530 Message-Id: <20240826170606.255718-5-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826170606.255718-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01Ta0xTZxjOudAe2LodLupHswh0mQY3oJ1t/SAyXEQ9C2ZilhjjlmADBwqU tullE3djY8N5qQiCSEHBG0pxMK6iXEQ6JAwoU1AEKbcBRjrGpZuOQehOOXXz3/O+3/O8z/e8 3zkE5vU7h08kKnW0RilTCDgeeJ05cGOQ/UZXvLBw7A1YZs3kQJt5AYFn5hYx6LA+QeFAy00U lpa1obAgLx2FExVGDFZmEvC3ITsXLpaYuLDNMcOB2a0PEdg0+Da8f3EXbGzqwGFRySQXHu+v 58Cr7SsorFsqwmC5bRaHPcZC7ra1VG9fFNUzXIlTZ7J/4VC93XqqynSUQ1Vf/ppqKLajVMNA GoeanxzEqZM1JoTqKv6ZS9mr1ke/eiB5q5yWxdEaf1oZq4pLVCaEC6I+itkeI5EKRUGiULhF 4K+UpdDhgsjd0UE7ExVMXIH/pzKFnmlFy7RaQch7WzUqvY72l6u0unABrY5TqMXqYK0sRatX JgQraV2YSCh8V8IQDybLpyzTuHrM49Bg00U8DbERxxB3ApBiUNTZzTmGeBBeZAMCzJeGuWyx gIBeazvOFs+Yk4c27IVk1tTvYjUh4OlfI67CjoASYwYjIQgOGQh+Pa139n3IdBRU/vjPqglG NqAgx/jEzTnKmwwFf8zU4E6Mk2+Bmv7vVjGP6RvuduGsnR/Iv/+c68TuZBhwzM1yWY4n6Mif WOVgDCe9tgBzGgAy3R2cXhxbvQUgI8H0iQPsHG8w3V7DZTEfPM3McOFkMDo+6vL6AtRXn3Rj cQRIW37k5hyDMWEqboWwVq8Bw9IEyk7ngR8yvFh2ABjOnnQp14Gxs5ddmAKdK+MIux8Ds6wj ZdgpxM/4UgLjSwmM/7sVI5gJ8aXV2pQEWitRi5T0Z/+9bKwqpQpZ/ew3fVCPWEfn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WFOem5yYb FhjmpZbrFSfmFpfmpesl5+duYgTHqZbGDsZ78//pHWJk4mA8xCjBwawkwit3+WSaEG9KYmVV alF+fFFpTmrxIUZpDhYlcV7DGbNThATSE0tSs1NTC1KLYLJMHJxSDUxXhDqYm44/uszXw3Hf +qTy0xe1j5pOXV6az1rkLeGfebx542ebtIodq/ZM4xdIKrK6WxFx5+G7or/Hw38W7hY0vGpU Z7fy5hJfz3k1nGKce85r3Vmdc+v5sgmLry/93ssmK6IQUte808BQS+aG3Yai5Z++xGfWPXx4 OFhuilWBOP92410PHlQ0mZ0q6/ErbCp/euaKmPv3uIs9W/avPrnMkTHQZ6ao6QKZJqn4zhQ5 E+Ufk7U5NazPCFrGrXTSDbPmOVwX5zmlzrTSijm2WE/2Ytehe06MbN+ehwmVz2dhs5r4OcKs RrmDW3l6+z9li+bt6RlfPk/e4Pfg/b5tckI7ni2PzYpJvPzjZ9GpT0osxRmJhlrMRcWJAMUC 7xRCAwAA X-CMS-MailID: 20240826171426epcas5p13c5ffabd6a05ee357bf4e9f78bc5de44 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240826171426epcas5p13c5ffabd6a05ee357bf4e9f78bc5de44 References: <20240826170606.255718-1-joshi.k@samsung.com> From: Nitesh Shetty The incoming hint value maybe either life hint or placement hint. Make SCSI interpret only temperature-based write life 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 699f4f9674d9..32b8a841c497 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_LIFE_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_LIFE_HINT(rq->write_hint)) { ret = sd_setup_rw10_cmnd(cmd, write, lba, nr_blocks, protect | fua); } else { From patchwork Mon Aug 26 17:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 13778237 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 2616C198A0E for ; Mon, 26 Aug 2024 17:14:36 +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=1724692478; cv=none; b=DXx3Ym1NgVXFOjLRqk7trsEhoA/NbIYq8BcfSbwqRnmVXY+LwBTyplxrPTm+vtBrpZeWq0XUTzBn2+KAYbKY9QS7IqglwtvT75peeOr+AqjtrXCgeAZ0dIJ2klxBD/WamZ7T/879li3q7uf2diW73Tj/aFevRQjDJC0VyDHdObs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724692478; c=relaxed/simple; bh=xt2LPYyXQ00HT9y64535LFuaSA1NJuGaMN3kkUbOXTo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version: Content-Type:References; b=SvTcMeaZrE5txSb/1lqOfPmQf2Zmj4E7y/y0v1zVLDfO3jt+iKdeVdhek4OvqfCiTam0JLOcJ2577tiTNNDZe16DcJzQFQHMlIBj//pkwNXR4GJwMPJnTw362yTlph6wLwRvXh2L4hrTjdEzm7YSJxRy5dohAWWdBDAwAIGxqdw= 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=iH8b29yr; 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="iH8b29yr" Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240826171434epoutp0498aca9f83a891c58056d9510b30cc5be~vVqrmqjr20751607516epoutp04a for ; Mon, 26 Aug 2024 17:14:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240826171434epoutp0498aca9f83a891c58056d9510b30cc5be~vVqrmqjr20751607516epoutp04a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1724692474; bh=8iPZaxnpfFrIc7zaxv8ZaN+SPBoGhDtwQfdoxDKuShI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iH8b29yrbZjHaH35JXRSp1sDkUVuN+m8jfDoWxYmsvFlYohHpAhsxfx6FzRyWc2t/ GEoMMKY7w7BA5b64fMb5RtGTgk1WqTi4cEB/kFYqQhZDd2rKhJgvP3e7NW/NV53LIj wJG1saSf3E3XZlaEsh+uUuMRKzvaqWBb6l82X6WM= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20240826171432epcas5p4bbeed704b13c2c041148a447d33bf5be~vVqqRDdqX3116731167epcas5p4Q; Mon, 26 Aug 2024 17:14:32 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.181]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4Wsy2v279bz4x9Pp; Mon, 26 Aug 2024 17:14:31 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 81.B3.09642.6F7BCC66; Tue, 27 Aug 2024 02:14:31 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20240826171430epcas5p3d8e34a266ced7b3ea0df2a11b83292ae~vVqoOYF0n1118211182epcas5p3m; Mon, 26 Aug 2024 17:14:30 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240826171430epsmtrp2a8d6ae6dc2221cc5f2dd7ba34e9c1b7e~vVqoLASCB3048030480epsmtrp2m; Mon, 26 Aug 2024 17:14:30 +0000 (GMT) X-AuditID: b6c32a4b-879fa700000025aa-5b-66ccb7f6a7a5 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id DF.51.19367.6F7BCC66; Tue, 27 Aug 2024 02:14:30 +0900 (KST) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240826171426epsmtip243cd9f8a60035672848defe83d52dea1~vVqkKvu2X0834608346epsmtip2P; Mon, 26 Aug 2024 17:14:26 +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, 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 v4 5/5] nvme: enable FDP support Date: Mon, 26 Aug 2024 22:36:06 +0530 Message-Id: <20240826170606.255718-6-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826170606.255718-1-joshi.k@samsung.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Ta0xTZxjHcy6cHgydB9DwShZgNW4CQlug5a0T0Uj0IEQxyxbih9UODheB tvS06pzbCGxMBORihFmGEAWcVVbucqtTroGhEBDlIgwYpAF0ol1gCBtrKTq//Z7n/f/f53ne C4k5vCScyVi5mlHJZfE8YhNe1+ru7rV0pydKYHyMwVtjWQScb32FwLyFZQyujRlROHyvAYU3 b7WjsKGsnAML8lNQOK3XYrAyi4R/PDVx4HKZjgPb154TMLflMQINI56w/9oh2GzowmFR2QwH pj+pJ+CNzn9RWLdShMFf5l/gsFf7E2efEz3wKITuHa/E6bzcboIeeKChq3RpBF1d8i3dVGxC 6abhJIJ+OTOC0xdrdAjdU9zGoU1VLmF2x+P2xDCySEblxsgjFJGx8ugAXsgn0gNSkVgg9BJK oD/PTS5LYAJ4QaFhXgdj480z89xOyeI15lSYjGV5/L17VAqNmnGLUbDqAB6jjIxX+im9WVkC q5FHe8sZ9W6hQOAjMgtPxMXUau8RyruiM0OLGXgSctPzAmJLAsoPzOpT0QvIJtKBakJAxWgt xxq8QkDW7SHsbTBbch97Y3ky2EZYFxoQ8FtNH24NTAgw9iyaVSRJUO6g75LGkt9CpaCgsvz1 ugOjRlDQNPszYhE5UgKQvMJadsWpHaCtQGdjYS4lAdl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FPWrsKZ7z0dGHMlXweY utRKghnKFW6dGmDjJ+Ykh8I5udeaAzYhBfwTXKZffrxtJBZTAa1HNLAmacqHft1SiUcDG1JA FQH6y9Bn3AKc6MjWUcKS7WjteC9hkb4DOtY4ZhUNSBKn3OhX15XmvT11HaHPdedj5gGlPiJ0 V3I+YpbsKG/63JjCfAij5tOVyTorc7alVtBX1WmIpcCFTmr8OVFmTa2kTYMDE1nwz9HWZRAW fwZdk/QBM2f0nx9ZkIxeBRQ/CfGTUCpAdMCBkylCg0MDZUs9FWyoQikN9gw8GpoLJp7qvr0Y aLL/eBoAQgIDoElUZG8rbKoJEtiK2RMnOfnR/XKlhFMYgDOJiZxsXSVqsYAKZsO4Ixwn4+T/ KUJaz1IhmwhfVW/enYbBm9tciuJfFe7lTqwNUOm9ZwbEjZgCo84Xl9dnVNQuqjwlHXUEbf4B rs7PYwybnt092GiV+O596Ybutn33SvasV2oHe5rFFzV2hgcRM+f6R7ndLeGJy8KpCeFnhY6O T+W3+FFj71PrlO7O1B3oMSj0ejGlPqQivGXevtjADpOofe6Gt1m/d5Wd9n057WXpDW5OsXg4 3eGSEx8Tt2xbn1db+s6s+abhhIhVaasXdvRPuW/EPhl4YwP7+ULr28zDnSnO2/OlM/LUvux0 /ezarwPSa116h+GgM9XfFCO7F/hIcqBR4zd7WN+S+3NxOi7acjvcge3O7lyglZEiTBHCLnVH 5Qr2L7cQEX5DAwAA X-CMS-MailID: 20240826171430epcas5p3d8e34a266ced7b3ea0df2a11b83292ae X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240826171430epcas5p3d8e34a266ced7b3ea0df2a11b83292ae References: <20240826170606.255718-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 33fa01c599ad..f93abd7fb163 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -43,6 +43,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"); @@ -656,6 +670,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); } @@ -958,6 +973,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) @@ -1077,6 +1103,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); @@ -2113,6 +2141,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) { @@ -2204,6 +2278,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 ae5314d32943..7516823ff8dd 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -450,6 +450,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 @@ -471,6 +473,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 7b2ae2e43544..12d8db13b66e 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; }; };