From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/nvme/target/nvmet.h

Change-Id: Idc76180a8600aeb79485137a311462911cfbd50d
---
 drivers/nvme/target/nvmet.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -22,6 +22,11 @@
 #include <linux/blkdev.h>
 #include <linux/radix-tree.h>
 #include <linux/t10-pi.h>
+#include <linux/xarray.h>
+
+#ifdef HAVE_BLK_INTEGRITY_H
+#define HAVE_BLKDEV_BIO_INTEGRITY_BYTES
+#endif
 
 #define NVMET_DEFAULT_VS		NVME_VS(1, 3, 0)
 
@@ -401,6 +406,9 @@ struct nvmet_req {
 	struct nvmet_ns		*ns;
 	struct scatterlist	*sg;
 	struct scatterlist	*metadata_sg;
+#ifdef HAVE_RH7_STRUCT_BIO_AUX
+	struct bio_aux		bio_aux;
+#endif
 	struct bio_vec		inline_bvec[NVMET_MAX_INLINE_BIOVEC];
 	union {
 		struct {
@@ -408,7 +416,9 @@ struct nvmet_req {
 		} b;
 		struct {
 			bool			mpool_alloc;
+#ifdef HAVE_FS_HAS_KIOCB
 			struct kiocb            iocb;
+#endif
 			struct bio_vec          *bvec;
 			struct work_struct      work;
 		} f;
@@ -492,8 +502,12 @@ void nvmet_stop_keep_alive_timer(struct
 u16 nvmet_parse_connect_cmd(struct nvmet_req *req);
 void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id);
 u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req);
+#ifdef HAVE_FS_HAS_KIOCB
 u16 nvmet_file_parse_io_cmd(struct nvmet_req *req);
+#endif
+#ifdef HAVE_BIO_ADD_ZONE_APPEND_PAGE
 u16 nvmet_bdev_zns_parse_io_cmd(struct nvmet_req *req);
+#endif
 u16 nvmet_parse_admin_cmd(struct nvmet_req *req);
 u16 nvmet_parse_discovery_cmd(struct nvmet_req *req);
 u16 nvmet_parse_fabrics_cmd(struct nvmet_req *req);
@@ -565,8 +579,13 @@ void nvmet_offload_ctx_configfs_del(stru
 void nvmet_referral_enable(struct nvmet_port *parent, struct nvmet_port *port);
 void nvmet_referral_disable(struct nvmet_port *parent, struct nvmet_port *port);
 
+#ifdef CONFIG_COMPAT_SCATTERLIST_SG_PCOPY_TO_BUFFER
 u16 nvmet_copy_to_sgl(struct nvmet_req *req, off_t off, const void *buf,
 		size_t len);
+#else
+u16 nvmet_copy_to_sgl(struct nvmet_req *req, off_t off, void *buf,
+		size_t len);
+#endif
 u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf,
 		size_t len);
 u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len);
@@ -621,20 +640,30 @@ extern struct rw_semaphore nvmet_ana_sem
 bool nvmet_host_allowed(struct nvmet_subsys *subsys, const char *hostnqn);
 
 int nvmet_bdev_ns_enable(struct nvmet_ns *ns);
+#ifdef HAVE_FS_HAS_KIOCB
 int nvmet_file_ns_enable(struct nvmet_ns *ns);
+#endif
 void nvmet_bdev_ns_disable(struct nvmet_ns *ns);
+#ifdef HAVE_FS_HAS_KIOCB
 void nvmet_file_ns_disable(struct nvmet_ns *ns);
+#endif
 u16 nvmet_bdev_flush(struct nvmet_req *req);
 u16 nvmet_file_flush(struct nvmet_req *req);
 void nvmet_ns_changed(struct nvmet_subsys *subsys, u32 nsid);
 void nvmet_bdev_ns_revalidate(struct nvmet_ns *ns);
+#ifdef HAVE_FS_HAS_KIOCB
 int nvmet_file_ns_revalidate(struct nvmet_ns *ns);
+#endif
 void nvmet_ns_revalidate(struct nvmet_ns *ns);
+#ifdef HAVE_BLK_STATUS_T
 u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts);
+#endif
 
+#ifdef HAVE_BIO_ADD_ZONE_APPEND_PAGE
 bool nvmet_bdev_zns_enable(struct nvmet_ns *ns);
 void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req);
 void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req);
+#endif
 void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_append(struct nvmet_req *req);
