diff --git a/0001-LU-16327-llite-read_folio-release_folio-filler_t.patch b/0001-LU-16327-llite-read_folio-release_folio-filler_t.patch new file mode 100644 index 0000000000000000000000000000000000000000..4cbdd98fbd0da6fee2885fadadcc1cfad73aaca9 --- /dev/null +++ b/0001-LU-16327-llite-read_folio-release_folio-filler_t.patch @@ -0,0 +1,479 @@ +From b489be535aa07e15dbfa498d0fc920b893709846 Mon Sep 17 00:00:00 2001 +From: Shaun Tancheff +Date: Tue, 21 Mar 2023 00:37:00 -0500 +Subject: [PATCH 1/5] LU-16327 llite: read_folio, release_folio, filler_t + +Linux commit v5.18-rc5-221-gb7446e7cf15f + fs: Remove aop flags parameter from grab_cache_page_write_begin() +flags have been dropped from write_begin() and +grab_cache_page_write_begin() + +Linux commit v5.18-rc5-241-g5efe7448a142 + fs: Introduce aops->read_folio +Provide a ll_read_folio handler around ll_readpage + +Linux commit v5.18-rc5-280-ge9b5b23e957e + fs: Change the type of filler_t +Affects read_cache_page, provides a wrapper for read_cache_page +and wrappers for filler functions + +Linux commit v5.18-rc5-282-gfa29000b6b26 + fs: Add aops->release_folio +Provide an ll_release_folio function based on ll_releasepage + +Test-Parameters: trivial +HPE-bug-id: LUS-11357 +Signed-off-by: Shaun Tancheff +Change-Id: Ibd4ec1133c80cd0eb8400c4cd07b50e421dd35c5 +--- + lustre/autoconf/lustre-core.m4 | 130 +++++++++++++++++++++++++++++++-- + lustre/include/lustre_compat.h | 18 +++++ + lustre/llite/file.c | 14 +++- + lustre/llite/llite_internal.h | 3 + + lustre/llite/rw.c | 9 ++- + lustre/llite/rw26.c | 83 ++++++++++++++++++++- + lustre/mdc/mdc_request.c | 21 ++++-- + 7 files changed, 259 insertions(+), 19 deletions(-) + +diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 +index 0f7307242e..984ea8bcc7 100644 +--- a/lustre/autoconf/lustre-core.m4 ++++ b/lustre/autoconf/lustre-core.m4 +@@ -3126,27 +3126,126 @@ AC_DEFUN([LC_HAVE_DIRTY_FOLIO], [ + # linux commit v5.17-49-g8b9f3ac5b01d + # fs: introduce alloc_inode_sb() to allocate filesystems specific inode + # +-AC_DEFUN([LC_HAVE_ALLOC_INODE_SB], [ +-tmp_flags="$EXTRA_KCFLAGS" +-EXTRA_KCFLAGS="-Werror" +-LB_CHECK_COMPILE([if alloc_inode_sb() exists], +-alloc_inode_sb, [ ++AC_DEFUN([LC_SRC_HAVE_ALLOC_INODE_SB], [ ++ LB2_LINUX_TEST_SRC([alloc_inode_sb], [ + #include + ],[ + struct super_block *sb = NULL; + struct kmem_cache *cache = NULL; + + (void)alloc_inode_sb(sb, cache, GFP_NOFS); +- ],[ ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_ALLOC_INODE_SB], [ ++ AC_MSG_CHECKING([if alloc_inode_sb() exists]) ++ LB2_LINUX_TEST_RESULT([alloc_inode_sb], [ + AC_DEFINE(HAVE_ALLOC_INODE_SB, 1, + [alloc_inode_sb() exists]) + ]) +-EXTRA_KCFLAGS="$tmp_flags" + ]) # LC_HAVE_ALLOC_INODE_SB + + AC_DEFUN([LC_PROG_LINUX_SRC], []) + AC_DEFUN([LC_PROG_LINUX_RESULTS], []) + ++# ++# LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS ++# ++# Linux commit v5.18-rc5-221-gb7446e7cf15f ++# fs: Remove aop flags parameter from grab_cache_page_write_begin() ++# ++AC_DEFUN([LC_SRC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS], [ ++ LB2_LINUX_TEST_SRC([grab_cache_page_write_begin_with_flags], [ ++ #include ++ ],[ ++ struct address_space *mapping = NULL; ++ (void)grab_cache_page_write_begin(mapping, 0, 1); ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS], [ ++ AC_MSG_CHECKING([if grab_cache_page_write_begin() has flags argument]) ++ LB2_LINUX_TEST_RESULT([grab_cache_page_write_begin_with_flags], [ ++ AC_DEFINE(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS, 1, ++ [grab_cache_page_write_begin() has flags argument]) ++ ]) ++]) # LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS ++ ++# ++# LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO ++# ++# Linux commit v5.18-rc5-241-g5efe7448a142 ++# fs: Introduce aops->read_folio ++# ++AC_DEFUN([LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO], [ ++ LB2_LINUX_TEST_SRC([address_space_operations_read_folio], [ ++ #include ++ ],[ ++ struct address_space_operations *aops = NULL; ++ struct file *file = NULL; ++ struct folio *folio = NULL; ++ int err = aops->read_folio(file, folio); ++ (void)err; ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO], [ ++ AC_MSG_CHECKING([if struct address_space_operations() has read_folio()]) ++ LB2_LINUX_TEST_RESULT([address_space_operations_read_folio], [ ++ AC_DEFINE(HAVE_AOPS_READ_FOLIO, 1, ++ [struct address_space_operations() has read_folio()]) ++ ]) ++]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO ++ ++# ++# LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE ++# ++# Linux commit v5.18-rc5-280-ge9b5b23e957e ++# fs: Change the type of filler_t ++# ++AC_DEFUN([LC_SRC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE], [ ++ LB2_LINUX_TEST_SRC([read_cache_page_filler_with_file], [ ++ #include ++ static inline int _filler(struct file *file, struct folio *f) ++ { ++ return 0; ++ } ++ ],[ ++ struct address_space *mapping = NULL; ++ struct file *file = NULL; ++ struct page *page = read_cache_page(mapping, 0, _filler, file); ++ (void)page; ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE], [ ++ AC_MSG_CHECKING([if read_cache_page() filler_t needs struct file]) ++ LB2_LINUX_TEST_RESULT([read_cache_page_filler_with_file], [ ++ AC_DEFINE(HAVE_READ_CACHE_PAGE_WANTS_FILE, 1, ++ [read_cache_page() filler_t needs struct file]) ++ ]) ++]) # LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE ++ ++# ++# LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO ++# ++# Linux commit v5.18-rc5-282-gfa29000b6b26 ++# fs: Add aops->release_folio ++# ++AC_DEFUN([LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO], [ ++ LB2_LINUX_TEST_SRC([address_space_operations_release_folio], [ ++ #include ++ ],[ ++ struct address_space_operations *aops = NULL; ++ struct folio *folio = NULL; ++ int err = aops->release_folio(folio, GFP_KERNEL); ++ (void)err; ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO], [ ++ AC_MSG_CHECKING([if struct address_space_operations() has release_folio()]) ++ LB2_LINUX_TEST_RESULT([address_space_operations_release_folio], [ ++ AC_DEFINE(HAVE_AOPS_RELEASE_FOLIO, 1, ++ [struct address_space_operations() has release_folio()]) ++ ]) ++]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO ++ + # + # LC_PROG_LINUX + # +@@ -3354,10 +3453,19 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ + LC_SRC_HAVE_SECURITY_DENTRY_INIT_WITH_XATTR_NAME_ARG + LC_SRC_HAVE_KIOCB_COMPLETE_2ARGS + +- # 5.18 ++ # 5.17 + LC_SRC_HAVE_INVALIDATE_FOLIO + LC_SRC_HAVE_DIRTY_FOLIO + ++ # 5.18 ++ LC_SRC_HAVE_ALLOC_INODE_SB ++ ++ # 5.19 ++ LC_SRC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS ++ LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO ++ LC_SRC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE ++ LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO ++ + # kernel patch to extend integrity interface + LC_SRC_BIO_INTEGRITY_PREP_FN + ]) +@@ -3582,6 +3690,12 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ + # 5.18 + LC_HAVE_ALLOC_INODE_SB + ++ # 5.19 ++ LC_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS ++ LC_HAVE_ADDRESS_SPACE_OPERATIONS_READ_FOLIO ++ LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE ++ LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO ++ + # kernel patch to extend integrity interface + LC_BIO_INTEGRITY_PREP_FN + ]) +diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h +index 4f2bd8af4e..cfb6e03856 100644 +--- a/lustre/include/lustre_compat.h ++++ b/lustre/include/lustre_compat.h +@@ -620,4 +620,22 @@ static inline void cfs_delete_from_page_cache(struct page *page) + } + #endif + ++static inline struct page *ll_read_cache_page(struct address_space *mapping, ++ pgoff_t index, filler_t *filler, ++ void *data) ++{ ++#ifdef HAVE_READ_CACHE_PAGE_WANTS_FILE ++ struct page *page = NULL; ++ struct file dummy_file; ++ ++ dummy_file.f_ra.ra_pages = 32; /* unused, modified on ra error */ ++ dummy_file.private_data = data; ++ page = read_cache_page(mapping, index, filler, &dummy_file); ++ ++ return page; ++#else ++ return read_cache_page(mapping, index, filler, data); ++#endif /* HAVE_READ_CACHE_PAGE_WANTS_FILE */ ++} ++ + #endif /* _LUSTRE_COMPAT_H */ +diff --git a/lustre/llite/file.c b/lustre/llite/file.c +index 692e3e5ff9..f08e084250 100644 +--- a/lustre/llite/file.c ++++ b/lustre/llite/file.c +@@ -491,6 +491,16 @@ static inline int ll_dom_readpage(void *data, struct page *page) + return rc; + } + ++#ifdef HAVE_READ_CACHE_PAGE_WANTS_FILE ++static inline int ll_dom_read_folio(struct file *file, struct folio *folio0) ++{ ++ return ll_dom_readpage(file->private_data, folio_page(folio0, 0)); ++} ++#define USE_FILLER_DOM ll_dom_read_folio ++#else ++#define USE_FILLER_DOM ll_dom_readpage ++#endif ++ + void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req) + { + struct lu_env *env; +@@ -568,8 +578,8 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req) + if (lnb.lnb_len > PAGE_SIZE) + lnb.lnb_len = PAGE_SIZE; + +- vmpage = read_cache_page(mapping, index + start, +- ll_dom_readpage, &lnb); ++ vmpage = ll_read_cache_page(mapping, index + start, ++ USE_FILLER_DOM, &lnb); + if (IS_ERR(vmpage)) { + CWARN("%s: cannot fill page %lu for "DFID + " with data: rc = %li\n", +diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h +index 60ac65086b..4aa39e49ba 100644 +--- a/lustre/llite/llite_internal.h ++++ b/lustre/llite/llite_internal.h +@@ -1152,6 +1152,9 @@ void ll_update_times(struct ptlrpc_request *request, struct inode *inode); + int ll_writepage(struct page *page, struct writeback_control *wbc); + int ll_writepages(struct address_space *, struct writeback_control *wbc); + int ll_readpage(struct file *file, struct page *page); ++#ifdef HAVE_AOPS_READ_FOLIO ++int ll_read_folio(struct file *file, struct folio *folio); ++#endif + int ll_io_read_page(const struct lu_env *env, struct cl_io *io, + struct cl_page *page, struct file *file); + void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras); +diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c +index 49f1688a5f..d4b6a49157 100644 +--- a/lustre/llite/rw.c ++++ b/lustre/llite/rw.c +@@ -2041,7 +2041,7 @@ int ll_readpage(struct file *file, struct page *vmpage) + } else { + unlock_page(vmpage); + result = PTR_ERR(page); +- } ++ } + + out: + if (ra.cra_release != NULL) +@@ -2049,3 +2049,10 @@ out: + + RETURN(result); + } ++ ++#ifdef HAVE_AOPS_READ_FOLIO ++int ll_read_folio(struct file *file, struct folio *folio) ++{ ++ return ll_readpage(file, folio_page(folio, 0)); ++} ++#endif +diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c +index c07c321fbe..f4c79def2c 100644 +--- a/lustre/llite/rw26.c ++++ b/lustre/llite/rw26.c +@@ -166,6 +166,68 @@ static void ll_invalidatepage(struct page *vmpage, + } + #endif + ++#ifdef HAVE_AOPS_RELEASE_FOLIO ++static bool ll_release_folio(struct folio *folio, gfp_t wait) ++{ ++ struct lu_env *env; ++ struct cl_object *obj; ++ struct cl_page *clpage; ++ struct address_space *mapping; ++ struct page *vmpage; ++ int result = 0; ++ ++ LASSERT(folio_test_locked(folio)); ++ if (folio_test_writeback(folio) || folio_test_dirty(folio)) ++ return 0; ++ ++ mapping = folio->mapping; ++ if (mapping == NULL) ++ return 1; ++ ++ obj = ll_i2info(mapping->host)->lli_clob; ++ if (obj == NULL) ++ return 1; ++ ++ vmpage = folio_page(folio, 0); ++ clpage = cl_vmpage_page(vmpage, obj); ++ if (clpage == NULL) ++ return 1; ++ ++ env = cl_env_percpu_get(); ++ LASSERT(!IS_ERR(env)); ++ ++ /* we must not delete the cl_page if the vmpage is in use, otherwise we ++ * disconnect the vmpage from Lustre while it's still alive(!), which ++ * means we won't find it to discard on lock cancellation. ++ * ++ * References here are: caller + cl_page + page cache. ++ * Any other references are potentially transient and must be ignored. ++ */ ++ if (!cl_page_in_use(clpage) && !vmpage_in_use(vmpage, 1)) { ++ result = 1; ++ cl_page_delete(env, clpage); ++ } ++ ++ /* To use percpu env array, the call path can not be rescheduled; ++ * otherwise percpu array will be messed if ll_releaspage() called ++ * again on the same CPU. ++ * ++ * If this page holds the last refc of cl_object, the following ++ * call path may cause reschedule: ++ * cl_page_put -> cl_page_free -> cl_object_put -> ++ * lu_object_put -> lu_object_free -> lov_delete_raid0. ++ * ++ * However, the kernel can't get rid of this inode until all pages have ++ * been cleaned up. Now that we hold page lock here, it's pretty safe ++ * that we won't get into object delete path. ++ */ ++ LASSERT(cl_object_refc(obj) > 1); ++ cl_page_put(env, clpage); ++ ++ cl_env_percpu_put(env); ++ return result; ++} ++#else /* !HAVE_AOPS_RELEASE_FOLIO */ + #ifdef HAVE_RELEASEPAGE_WITH_INT + #define RELEASEPAGE_ARG_TYPE int + #else +@@ -229,6 +291,7 @@ static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask) + cl_env_percpu_put(env); + return result; + } ++#endif /* HAVE_AOPS_RELEASE_FOLIO */ + + static ssize_t ll_get_user_pages(int rw, struct iov_iter *iter, + struct page ***pages, ssize_t *npages, +@@ -707,7 +770,10 @@ static int ll_tiny_write_begin(struct page *vmpage, struct address_space *mappin + } + + static int ll_write_begin(struct file *file, struct address_space *mapping, +- loff_t pos, unsigned len, unsigned flags, ++ loff_t pos, unsigned int len, ++#ifdef HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS ++ unsigned int flags, ++#endif + struct page **pagep, void **fsdata) + { + struct ll_cl_context *lcc = NULL; +@@ -780,8 +846,11 @@ again: + GOTO(out, result); + + if (vmpage == NULL) { +- vmpage = grab_cache_page_write_begin(mapping, index, +- flags); ++ vmpage = grab_cache_page_write_begin(mapping, index ++#ifdef HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN_WITH_FLAGS ++ , flags ++#endif ++ ); + if (vmpage == NULL) + GOTO(out, result = -ENOMEM); + } +@@ -987,8 +1056,16 @@ const struct address_space_operations ll_aops = { + #else + .invalidatepage = ll_invalidatepage, + #endif ++#ifdef HAVE_AOPS_READ_FOLIO ++ .read_folio = ll_read_folio, ++#else + .readpage = ll_readpage, ++#endif ++#ifdef HAVE_AOPS_RELEASE_FOLIO ++ .release_folio = ll_release_folio, ++#else + .releasepage = (void *)ll_releasepage, ++#endif + .direct_IO = ll_direct_IO, + .writepage = ll_writepage, + .writepages = ll_writepages, +diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c +index 0fcdb4982d..1140fab704 100644 +--- a/lustre/mdc/mdc_request.c ++++ b/lustre/mdc/mdc_request.c +@@ -1330,7 +1330,7 @@ struct readpage_param { + * in PAGE_SIZE (if PAGE_SIZE greater than LU_PAGE_SIZE), and the + * lu_dirpage for this integrated page will be adjusted. + **/ +-static int mdc_read_page_remote(void *data, struct page *page0) ++static int ll_mdc_read_page_remote(void *data, struct page *page0) + { + struct readpage_param *rp = data; + struct page **page_pool; +@@ -1426,6 +1426,17 @@ static int mdc_read_page_remote(void *data, struct page *page0) + RETURN(rc); + } + ++#ifdef HAVE_READ_CACHE_PAGE_WANTS_FILE ++static inline int mdc_read_folio_remote(struct file *file, struct folio *folio) ++{ ++ return ll_mdc_read_page_remote(file->private_data, ++ folio_page(folio, 0)); ++} ++#define USE_FILLER_MDC mdc_read_folio_remote ++#else ++#define USE_FILLER_MDC ll_mdc_read_page_remote ++#endif ++ + /** + * Read dir page from cache first, if it can not find it, read it from + * server and add into the cache. +@@ -1508,10 +1519,10 @@ static int mdc_read_page(struct obd_export *exp, struct md_op_data *op_data, + + rp_param.rp_exp = exp; + rp_param.rp_mod = op_data; +- page = read_cache_page(mapping, +- hash_x_index(rp_param.rp_off, +- rp_param.rp_hash64), +- mdc_read_page_remote, &rp_param); ++ page = ll_read_cache_page(mapping, ++ hash_x_index(rp_param.rp_off, ++ rp_param.rp_hash64), ++ USE_FILLER_MDC, &rp_param); + if (IS_ERR(page)) { + CDEBUG(D_INFO, "%s: read cache page: "DFID" at %llu: %ld\n", + exp->exp_obd->obd_name, PFID(&op_data->op_fid1), +-- +2.39.1 + diff --git a/0002-LU-16328-llite-Linux-6.0-migrate_folio-vfs_setxattr.patch b/0002-LU-16328-llite-Linux-6.0-migrate_folio-vfs_setxattr.patch new file mode 100644 index 0000000000000000000000000000000000000000..5852d02dfeb42aa0e4b09e321b15e04e30313841 --- /dev/null +++ b/0002-LU-16328-llite-Linux-6.0-migrate_folio-vfs_setxattr.patch @@ -0,0 +1,273 @@ +From 3887e778a97d1b9c5f039252650e75d22a4a7692 Mon Sep 17 00:00:00 2001 +From: Shaun Tancheff +Date: Sat, 14 Jan 2023 02:42:19 -0600 +Subject: [PATCH 2/5] LU-16328 llite: Linux 6.0 migrate_folio, vfs_setxattr + +Linux commit v5.19-rc3-392-g5490da4f06d1 + fs: Add aops->migrate_folio + +Linux commit v5.19-rc4-52-ge33c267ab70d + mm: shrinkers: provide shrinkers with names + +From Linux commit v5.19-rc5-17-g0c5fd887d2bb + acl: move idmapped mount fixup into vfs_{g,s}etxattr() +Until Linux commit v6.0-rc3-6-g6344e66970c6 + xattr: constify value argument in vfs_setxattr() +Cast away const when required. + +Linux commit v5.19-10313-geba2d3d79829 + get rid of non-advancing variants +iov_iter_get_pages_alloc2() replaces iov_iter_get_pages_alloc() + +Test-Parameters: trivial +HPE-bug-id: LUS-11358 +Signed-off-by: Shaun Tancheff +Change-Id: Id1fa6db94172c0a61008ba4b066907950bdd6473 +--- + lustre/autoconf/lustre-core.m4 | 118 +++++++++++++++++++++++++++++++++ + lustre/include/lustre_compat.h | 14 +++- + lustre/llite/rw26.c | 28 ++++++-- + 3 files changed, 154 insertions(+), 6 deletions(-) + +diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 +index 984ea8bcc7..f01f22a265 100644 +--- a/lustre/autoconf/lustre-core.m4 ++++ b/lustre/autoconf/lustre-core.m4 +@@ -3246,6 +3246,112 @@ AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO], [ + ]) + ]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO + ++# ++# LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO ++# ++# Linux commit v5.19-rc3-392-g5490da4f06d1 ++# fs: Add aops->migrate_folio ++# ++AC_DEFUN([LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO], [ ++ LB2_LINUX_TEST_SRC([address_space_operations_migrate_folio], [ ++ #include ++ ],[ ++ struct address_space_operations *aops = NULL; ++ struct address_space *m = NULL; ++ struct folio *src = NULL; ++ struct folio *dst = NULL; ++ int err = aops->migrate_folio(m, dst, src, MIGRATE_ASYNC); ++ (void)err; ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO], [ ++ AC_MSG_CHECKING([if struct address_space_operations() has migrate_folio()]) ++ LB2_LINUX_TEST_RESULT([address_space_operations_migrate_folio], [ ++ AC_DEFINE(HAVE_AOPS_MIGRATE_FOLIO, 1, ++ [struct address_space_operations() has migrate_folio()]) ++ ]) ++]) # LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO ++ ++# ++# LC_REGISTER_SHRINKER_FORMAT_NAMED ++# ++# Linux commit v5.19-rc4-52-ge33c267ab70d ++# mm: shrinkers: provide shrinkers with names ++# ++AC_DEFUN([LC_SRC_REGISTER_SHRINKER_FORMAT_NAMED], [ ++ LB2_LINUX_TEST_SRC([register_shrinker_format], [ ++ #include ++ ],[ ++ if (register_shrinker(NULL, "lustre-%ps", __func__)) ++ unregister_shrinker(NULL); ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_REGISTER_SHRINKER_FORMAT_NAMED], [ ++ AC_MSG_CHECKING([if register_shrinker() returns status]) ++ LB2_LINUX_TEST_RESULT([address_space_operations_migrate_folio], [ ++ AC_DEFINE(HAVE_REGISTER_SHRINKER_FORMAT_NAMED, 1, ++ [register_shrinker() returns status]) ++ ]) ++]) # LC_REGISTER_SHRINKER_FORMAT_NAMED ++ ++# ++# LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE ++# ++# From Linux commit v5.19-rc5-17-g0c5fd887d2bb ++# acl: move idmapped mount fixup into vfs_{g,s}etxattr() ++# Until Linux commit v6.0-rc3-6-g6344e66970c6 ++# xattr: constify value argument in vfs_setxattr() ++# ++AC_DEFUN([LC_SRC_HAVE_VFS_SETXATTR_NON_CONST_VALUE], [ ++ LB2_LINUX_TEST_SRC([vfs_setxattr_non_const_value_arg], [ ++ #include ++ ],[ ++ struct dentry *de = NULL; ++ const char *name = "an.xattr"; ++ const void *value = NULL; ++ int err = vfs_setxattr(&init_user_ns, de, name, value, 0, 0); ++ (void)err; ++ ],[-Werror]) ++]) # LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE ++AC_DEFUN([LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE], [ ++ AC_MSG_CHECKING([if vfs_setxattr() value argument is non-const]) ++ LB2_LINUX_TEST_RESULT([vfs_setxattr_non_const_value_arg], [ ++ AC_DEFINE([VFS_SETXATTR_VALUE(value)], ++ [(value)], ++ [vfs_setxattr() value argument is const void *]) ++ ],[ ++ AC_DEFINE([VFS_SETXATTR_VALUE(value)], ++ [((void *)(value))], ++ [vfs_setxattr() value argument is non-const]) ++ ]) ++]) # LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE ++ ++# ++# LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 ++# ++# Linux commit v5.19-10313-geba2d3d79829 ++# get rid of non-advancing variants ++# ++AC_DEFUN([LC_SRC_HAVE_IOV_ITER_GET_PAGES_ALLOC2], [ ++ LB2_LINUX_TEST_SRC([iov_iter_get_pages_alloc2], [ ++ #include ++ ],[ ++ struct iov_iter *iter = NULL; ++ struct page ***pages = NULL; ++ size_t maxsize = 1; ++ size_t start; ++ size_t result __attribute__ ((unused)); ++ result = iov_iter_get_pages_alloc2(iter, pages, maxsize, &start); ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2], [ ++ AC_MSG_CHECKING([if iov_iter_get_pages_alloc2() is available]) ++ LB2_LINUX_TEST_RESULT([iov_iter_get_pages_alloc2], [ ++ AC_DEFINE(HAVE_IOV_ITER_GET_PAGES_ALLOC2, 1, ++ [iov_iter_get_pages_alloc2() is available]) ++ ]) ++]) # LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 ++ + # + # LC_PROG_LINUX + # +@@ -3466,6 +3572,12 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ + LC_SRC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE + LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO + ++ # 6.0 ++ LC_SRC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO ++ LC_SRC_REGISTER_SHRINKER_FORMAT_NAMED ++ LC_SRC_HAVE_VFS_SETXATTR_NON_CONST_VALUE ++ LC_SRC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 ++ + # kernel patch to extend integrity interface + LC_SRC_BIO_INTEGRITY_PREP_FN + ]) +@@ -3696,6 +3808,12 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ + LC_HAVE_READ_CACHE_PAGE_FILLER_WITH_FILE + LC_HAVE_ADDRESS_SPACE_OPERATIONS_RELEASE_FOLIO + ++ # 6.0 ++ LC_HAVE_ADDRESS_SPACE_OPERATIONS_MIGRATE_FOLIO ++ LC_REGISTER_SHRINKER_FORMAT_NAMED ++ LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE ++ LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 ++ + # kernel patch to extend integrity interface + LC_BIO_INTEGRITY_PREP_FN + ]) +diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h +index cfb6e03856..726d99fe9a 100644 +--- a/lustre/include/lustre_compat.h ++++ b/lustre/include/lustre_compat.h +@@ -505,12 +505,20 @@ static inline int ll_vfs_getxattr(struct dentry *dentry, struct inode *inode, + #endif + } + ++/* ++ * v5.19-rc5-17-g0c5fd887d2bb ++ * acl: move idmapped mount fixup into vfs_{g,s}etxattr() ++ * ++ * v6.0-rc3-6-g6344e66970c6 ++ * xattr: constify value argument in vfs_setxattr() ++ */ + static inline int ll_vfs_setxattr(struct dentry *dentry, struct inode *inode, + const char *name, + const void *value, size_t size, int flags) + { + #ifdef HAVE_USER_NAMESPACE_ARG +- return vfs_setxattr(&init_user_ns, dentry, name, value, size, flags); ++ return vfs_setxattr(&init_user_ns, dentry, name, ++ VFS_SETXATTR_VALUE(value), size, flags); + #elif defined(HAVE_VFS_SETXATTR) + return __vfs_setxattr(dentry, inode, name, value, size, flags); + #else +@@ -559,7 +567,9 @@ static inline bool is_root_inode(struct inode *inode) + } + #endif + +-#ifndef HAVE_REGISTER_SHRINKER_RET ++#ifdef HAVE_REGISTER_SHRINKER_FORMAT_NAMED ++#define register_shrinker(_s) register_shrinker((_s), "%ps", (_s)) ++#elif !defined(HAVE_REGISTER_SHRINKER_RET) + #define register_shrinker(_s) (register_shrinker(_s), 0) + #endif + +diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c +index f4c79def2c..b24b5ea517 100644 +--- a/lustre/llite/rw26.c ++++ b/lustre/llite/rw26.c +@@ -304,8 +304,15 @@ static ssize_t ll_get_user_pages(int rw, struct iov_iter *iter, + /* + * iov_iter_get_pages_alloc() is introduced in 3.16 similar + * to HAVE_DIO_ITER. ++ * Linux commit v5.19-10313-geba2d3d79829 ++ * get rid of non-advancing variants ++ * iov_iter_get_pages_alloc() -> iov_iter_get_pages_alloc2() + */ ++#ifdef HAVE_IOV_ITER_GET_PAGES_ALLOC2 ++ result = iov_iter_get_pages_alloc2(iter, pages, maxsize, &start); ++#else + result = iov_iter_get_pages_alloc(iter, pages, maxsize, &start); ++#endif + if (result > 0) + *npages = DIV_ROUND_UP(result + start, PAGE_SIZE); + +@@ -1035,13 +1042,24 @@ out: + RETURN(result >= 0 ? copied : result); + } + +-#ifdef CONFIG_MIGRATION ++#ifdef HAVE_AOPS_MIGRATE_FOLIO ++/* ++ * Linux commit v5.19-rc3-392-g5490da4f06d1 ++ * fs: Add aops->migrate_folio ++ */ ++static int ll_migrate_folio(struct address_space *mapping, struct folio *dst, ++ struct folio *src, enum migrate_mode mode) ++{ ++ /* Always fail page migration until we have a proper implementation */ ++ return -EIO; ++} ++#elif defined(CONFIG_MIGRATION) + static int ll_migratepage(struct address_space *mapping, + struct page *newpage, struct page *page, + enum migrate_mode mode) + { +- /* Always fail page migration until we have a proper implementation */ +- return -EIO; ++ /* Always fail page migration until we have a proper implementation */ ++ return -EIO; + } + #endif + +@@ -1071,7 +1089,9 @@ const struct address_space_operations ll_aops = { + .writepages = ll_writepages, + .write_begin = ll_write_begin, + .write_end = ll_write_end, +-#ifdef CONFIG_MIGRATION ++#ifdef HAVE_AOPS_MIGRATE_FOLIO ++ .migrate_folio = ll_migrate_folio, ++#elif defined(CONFIG_MIGRATION) + .migratepage = ll_migratepage, + #endif + }; +-- +2.39.1 + diff --git a/0003-LU-16351-llite-Linux-6.1-prandom-folios_contig-vma_i.patch b/0003-LU-16351-llite-Linux-6.1-prandom-folios_contig-vma_i.patch new file mode 100644 index 0000000000000000000000000000000000000000..e6e13b138da9c92c5aa25fdcdfddfcd2b3f1f555 --- /dev/null +++ b/0003-LU-16351-llite-Linux-6.1-prandom-folios_contig-vma_i.patch @@ -0,0 +1,621 @@ +From 344c33e14c46a74426f31e5a47d282901b8a47a3 Mon Sep 17 00:00:00 2001 +From: Shaun Tancheff +Date: Fri, 27 Jan 2023 00:54:42 -0600 +Subject: [PATCH 3/5] LU-16351 llite: Linux 6.1 prandom, folios_contig, + vma_iterator + +Linux commit v4.10-rc3-6-gc440408cf690 + random: convert get_random_int/long into get_random_u32/u64 +Linux commit v6.0-11338-gde492c83cae0 + prandom: remove unused functions + +prandom_u32 is a wrapper around get_random_u32, change users +of prandom_u32 to get_random_u32 and provide a fallback +to prandom_u32 when get_random_u32 is not available. + +Linux commit v6.0-rc1-2-g25885a35a720 + Change calling conventions for filldir_t +Add a test for the new filldir_t signature +Provide wrappers for transition from int (error code) to bool + +Linux commit v6.0-rc3-94-g35b471467f88 + filemap: add filemap_get_folios_contig() +Provide a wrapper and fallback to find_get_pages_contig + +Linux commit v6.0-rc3-225-gf39af05949a4 + mm: add VMA iterator +Use vma_iterator and for_each_vma when available. + +Test-Parameters: trivial +HPE-bug-id: LUS-11377 +Signed-off-by: Shaun Tancheff +Change-Id: I23dc23d0252e1995555b6685f5cf7c207edf642b +--- + contrib/scripts/spelling.txt | 3 +- + lustre/autoconf/lustre-core.m4 | 101 ++++++++++++++++++++++++++++++ + lustre/llite/llite_mmap.c | 22 +++++-- + lustre/llite/llite_nfs.c | 51 ++++++++++----- + lustre/llite/vvp_dev.c | 27 +++++++- + lustre/obdclass/llog_test.c | 2 +- + lustre/obdclass/lu_object.c | 2 +- + lustre/obdclass/lu_tgt_descs.c | 8 ++- + lustre/osd-ldiskfs/osd_handler.c | 8 ++- + lustre/osd-ldiskfs/osd_internal.h | 18 ++++++ + lustre/osd-ldiskfs/osd_scrub.c | 61 ++++++++++-------- + 11 files changed, 248 insertions(+), 55 deletions(-) + +diff --git a/contrib/scripts/spelling.txt b/contrib/scripts/spelling.txt +index b79e5a5b70..fa94a23d25 100644 +--- a/contrib/scripts/spelling.txt ++++ b/contrib/scripts/spelling.txt +@@ -84,7 +84,7 @@ CFS_PAGE_MASK||PAGE_MASK + CFS_PAGE_SIZE||PAGE_SIZE + cfs_proc_dir_entry_t||struct proc_dir_entry + cfs_rcu_head_t||struct rcu_head +-cfs_rand||prandom_u32 ++cfs_rand||get_random_u32 + cfs_srand||add_device_randomness + cfs_trimwhite||strim + cfs_time_add_64||ktime_add +@@ -197,6 +197,7 @@ PAGE_CACHE_MASK||PAGE_MASK + page_cache_release||put_page + PAGE_CACHE_SHIFT||PAGE_SHIFT + PAGE_CACHE_SIZE||PAGE_SIZE ++prandom_u32||get_random_u32 + return seq_printf||seq_printf + setup_timer||cfs_timer_setup + = seq_printf||seq_printf +diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 +index f01f22a265..82f89dc04f 100644 +--- a/lustre/autoconf/lustre-core.m4 ++++ b/lustre/autoconf/lustre-core.m4 +@@ -3352,6 +3352,97 @@ AC_DEFUN([LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2], [ + ]) + ]) # LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 + ++# ++# LC_HAVE_GET_RANDOM_U32_AND_U64 ++# ++# Linux commit v4.10-rc3-6-gc440408cf690 ++# random: convert get_random_int/long into get_random_u32/u64 ++# Linux commit v6.0-11338-gde492c83cae0 ++# prandom: remove unused functions ++# ++AC_DEFUN([LC_SRC_HAVE_GET_RANDOM_U32_AND_U64], [ ++ LB2_LINUX_TEST_SRC([get_random_u32_and_u64], [ ++ #include ++ ],[ ++ u32 rand32 = get_random_u32(); ++ u64 rand64 = get_random_u64(); ++ (void)rand32; ++ (void)rand64; ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_GET_RANDOM_U32_AND_U64], [ ++ AC_MSG_CHECKING([if get_random_u32() and get_random_u64() are available]) ++ LB2_LINUX_TEST_RESULT([get_random_u32_and_u64], [ ++ AC_DEFINE(HAVE_GET_RANDOM_U32_AND_U64, 1, ++ [get_random_[u32|u64] are available]) ++ ],[ ++ AC_DEFINE([get_random_u32()], [prandom_u32()], ++ [get_random_u32() is not available, use prandom_u32]) ++ ]) ++]) # LC_HAVE_GET_RANDOM_U32_AND_U64 ++ ++# ++# LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL ++# ++# Linux commit v6.0-rc1-2-g25885a35a720 ++# Change calling conventions for filldir_t ++# ++AC_DEFUN([LC_SRC_NFS_FILLDIR_USE_CTX_RETURN_BOOL], [ ++ LB2_LINUX_TEST_SRC([filldir_ctx_return_bool], [ ++ #include ++ ],[ ++ bool filldir(struct dir_context *ctx, const char* name, ++ int i, loff_t off, u64 tmp, unsigned temp) ++ { ++ return 0; ++ } ++ ++ struct dir_context ctx = { ++ .actor = filldir, ++ }; ++ ++ ctx.actor(NULL, "test", 0, (loff_t) 0, 0, 0); ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL], [ ++ AC_MSG_CHECKING([if filldir_t uses struct dir_context and returns bool]) ++ LB2_LINUX_TEST_RESULT([filldir_ctx_return_bool], [ ++ AC_DEFINE(HAVE_FILLDIR_USE_CTX_RETURN_BOOL, 1, ++ [filldir_t needs struct dir_context and returns bool]) ++ AC_DEFINE(HAVE_FILLDIR_USE_CTX, 1, ++ [filldir_t needs struct dir_context as argument]) ++ AC_DEFINE(FILLDIR_TYPE, bool, ++ [filldir_t return type is bool or int]) ++ ],[ ++ AC_DEFINE(FILLDIR_TYPE, int, ++ [filldir_t return type is bool or int]) ++ ]) ++]) # LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL ++ ++# ++# LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG ++# ++# Linux commit v6.0-rc3-94-g35b471467f88 ++# filemap: add filemap_get_folios_contig() ++# ++AC_DEFUN([LC_SRC_HAVE_FILEMAP_GET_FOLIOS_CONTIG], [ ++ LB2_LINUX_TEST_SRC([filemap_get_folios_contig], [ ++ #include ++ ],[ ++ struct address_space *m = NULL; ++ pgoff_t start = 0; ++ struct folio_batch *fbatch = NULL; ++ (void)filemap_get_folios_contig(m, &start, ULONG_MAX, fbatch); ++ ],[-Werror]) ++]) ++AC_DEFUN([LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG], [ ++ AC_MSG_CHECKING([if filemap_get_folios_contig() is available]) ++ LB2_LINUX_TEST_RESULT([filldir_ctx_return_bool], [ ++ AC_DEFINE(HAVE_FILEMAP_GET_FOLIOS_CONTIG, 1, ++ [filemap_get_folios_contig() is available]) ++ ]) ++]) # LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG ++ + # + # LC_PROG_LINUX + # +@@ -3578,6 +3669,11 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ + LC_SRC_HAVE_VFS_SETXATTR_NON_CONST_VALUE + LC_SRC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 + ++ # 6.1 ++ LC_SRC_HAVE_GET_RANDOM_U32_AND_U64 ++ LC_SRC_NFS_FILLDIR_USE_CTX_RETURN_BOOL ++ LC_SRC_HAVE_FILEMAP_GET_FOLIOS_CONTIG ++ + # kernel patch to extend integrity interface + LC_SRC_BIO_INTEGRITY_PREP_FN + ]) +@@ -3814,6 +3910,11 @@ AC_DEFUN([LC_PROG_LINUX_RESULTS], [ + LC_HAVE_VFS_SETXATTR_NON_CONST_VALUE + LC_HAVE_IOV_ITER_GET_PAGES_ALLOC2 + ++ # 6.1 ++ LC_HAVE_GET_RANDOM_U32_AND_U64 ++ LC_NFS_FILLDIR_USE_CTX_RETURN_BOOL ++ LC_HAVE_FILEMAP_GET_FOLIOS_CONTIG ++ + # kernel patch to extend integrity interface + LC_BIO_INTEGRITY_PREP_FN + ]) +diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c +index af70ae68ba..7b95d6b49b 100644 +--- a/lustre/llite/llite_mmap.c ++++ b/lustre/llite/llite_mmap.c +@@ -51,18 +51,32 @@ void policy_from_vma(union ldlm_policy_data *policy, struct vm_area_struct *vma, + ~PAGE_MASK; + } + ++/* ++ * Linux commit v6.0-rc3-225-gf39af05949a4 ++ * mm: add VMA iterator ++ */ ++#ifndef VMA_ITERATOR ++#define vma_iterator vm_area_struct * ++#define vma_iter_init(vmip, mm, addr) *(vmip) = find_vma(mm, addr) ++#define for_each_vma(vmi, vma) \ ++ for (vma = vmi; vma != NULL; vma = vma->vm_next) ++#endif ++ + struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, +- size_t count) ++ size_t count) + { + struct vm_area_struct *vma, *ret = NULL; ++ struct vma_iterator vmi; ++ + ENTRY; + + /* mmap_lock must have been held by caller. */ + LASSERT(!mmap_write_trylock(mm)); + +- for (vma = find_vma(mm, addr); +- vma != NULL && vma->vm_start < (addr + count); +- vma = vma->vm_next) { ++ vma_iter_init(&vmi, mm, addr); ++ for_each_vma(vmi, vma) { ++ if (vma->vm_start < (addr + count)) ++ break; + if (vma->vm_ops && vma->vm_ops == &ll_file_vm_ops && + vma->vm_flags & VM_SHARED) { + ret = vma; +diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c +index 644aac2456..7d16d9d165 100644 +--- a/lustre/llite/llite_nfs.c ++++ b/lustre/llite/llite_nfs.c +@@ -198,19 +198,10 @@ static int ll_encode_fh(struct inode *inode, u32 *fh, int *plen, + RETURN(FILEID_LUSTRE); + } + +-static int +-#ifndef HAVE_FILLDIR_USE_CTX +-ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen, +- loff_t hash, u64 ino, unsigned type) ++static inline int ++do_nfs_get_name_filldir(struct ll_getname_data *lgd, const char *name, ++ int namelen, loff_t hash, u64 ino, unsigned int type) + { +- struct ll_getname_data *lgd = cookie; +-#else +-ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, int namelen, +- loff_t hash, u64 ino, unsigned type) +-{ +- struct ll_getname_data *lgd = +- container_of(ctx, struct ll_getname_data, ctx); +-#endif /* HAVE_FILLDIR_USE_CTX */ + /* + * It is hack to access lde_fid for comparison with lgd_fid. + * So the input 'name' must be part of the 'lu_dirent', and +@@ -232,11 +223,41 @@ ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, int namelen, + lgd->lgd_name[namelen] = 0; + lgd->lgd_found = 1; + } +- return lgd->lgd_found; ++ return lgd->lgd_found; ++} ++ ++#ifdef HAVE_FILLDIR_USE_CTX_RETURN_BOOL ++static bool ++ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, int namelen, ++ loff_t hash, u64 ino, unsigned int type) ++{ ++ struct ll_getname_data *lgd = ++ container_of(ctx, struct ll_getname_data, ctx); ++ int err = do_nfs_get_name_filldir(lgd, name, namelen, hash, ino, type); ++ ++ return err == 0; ++} ++#elif defined(HAVE_FILLDIR_USE_CTX) ++static int ++ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, int namelen, ++ loff_t hash, u64 ino, unsigned int type) ++{ ++ struct ll_getname_data *lgd = ++ container_of(ctx, struct ll_getname_data, ctx); ++ ++ return do_nfs_get_name_filldir(lgd, name, namelen, hash, ino, type); + } ++#else ++static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen, ++ loff_t hash, u64 ino, unsigned int type) ++{ ++ struct ll_getname_data *lgd = cookie; ++ ++ return do_nfs_get_name_filldir(lgd, name, namelen, hash, ino, type); ++} ++#endif /* HAVE_FILLDIR_USE_CTX */ + +-static int ll_get_name(struct dentry *dentry, char *name, +- struct dentry *child) ++static int ll_get_name(struct dentry *dentry, char *name, struct dentry *child) + { + struct inode *dir = dentry->d_inode; + struct ll_getname_data lgd = { +diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c +index 0a2fc5b25b..4036afce63 100644 +--- a/lustre/llite/vvp_dev.c ++++ b/lustre/llite/vvp_dev.c +@@ -386,6 +386,28 @@ struct vvp_seq_private { + loff_t vvp_prev_pos; + }; + ++unsigned int ll_filemap_get_one_page_contig(struct address_space *mapping, ++ pgoff_t start, struct page **pg) ++{ ++#ifdef HAVE_FILEMAP_GET_FOLIOS_CONTIG ++ struct folio_batch fbatch; ++ int nr; ++ ++ folio_batch_init(&fbatch); ++ *pg = NULL; ++ ++ nr = filemap_get_folios_contig(mapping, &start, start, &fbatch); ++ if (nr == PAGEVEC_SIZE) { ++ --nr; ++ *pg = folio_page(fbatch.folios[nr], 0); ++ return 1; ++ } ++ return 0; ++#else /* !HAVE_FILEMAP_GET_FOLIOS_CONTIG */ ++ return find_get_pages_contig(mapping, start, 1, pg); ++#endif ++} ++ + static struct page *vvp_pgcache_current(struct vvp_seq_private *priv) + { + struct lu_device *dev = &priv->vsp_sbi->ll_cl->cd_lu_dev; +@@ -416,8 +438,9 @@ static struct page *vvp_pgcache_current(struct vvp_seq_private *priv) + } + + inode = vvp_object_inode(priv->vsp_clob); +- nr = find_get_pages_contig(inode->i_mapping, +- priv->vsp_page_index, 1, &vmpage); ++ nr = ll_filemap_get_one_page_contig(inode->i_mapping, ++ priv->vsp_page_index, ++ &vmpage); + if (nr > 0) { + priv->vsp_page_index = vmpage->index; + break; +diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c +index 1a7cbdea7c..6b32d80e00 100644 +--- a/lustre/obdclass/llog_test.c ++++ b/lustre/obdclass/llog_test.c +@@ -2325,7 +2325,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) + ctxt->loc_dir = o; + llog_ctxt_put(ctxt); + +- llog_test_rand = prandom_u32(); ++ llog_test_rand = get_random_u32(); + + rc = llog_run_tests(&env, tgt); + if (rc) +diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c +index d2fbbd9087..5389a86620 100644 +--- a/lustre/obdclass/lu_object.c ++++ b/lustre/obdclass/lu_object.c +@@ -1135,7 +1135,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) + return -ENOMEM; + } + +- s->ls_bkt_seed = prandom_u32(); ++ s->ls_bkt_seed = get_random_u32(); + s->ls_bkt_cnt = max_t(long, 1 << LU_SITE_BKT_BITS, + 2 * num_possible_cpus()); + s->ls_bkt_cnt = roundup_pow_of_two(s->ls_bkt_cnt); +diff --git a/lustre/obdclass/lu_tgt_descs.c b/lustre/obdclass/lu_tgt_descs.c +index bfb5816430..fafbdfea27 100644 +--- a/lustre/obdclass/lu_tgt_descs.c ++++ b/lustre/obdclass/lu_tgt_descs.c +@@ -57,7 +57,9 @@ u64 lu_prandom_u64_max(u64 ep_ro) + u64 rand = 0; + + if (ep_ro) { +-#if BITS_PER_LONG == 32 ++#ifdef HAVE_GET_RANDOM_U32_AND_U64 ++ rand = get_random_u64() % ep_ro; ++#elif BITS_PER_LONG == 32 + /* + * If ep_ro > 32-bit, first generate the high + * 32 bits of the random number, then add in the low +@@ -69,9 +71,9 @@ u64 lu_prandom_u64_max(u64 ep_ro) + if (rand == (ep_ro & 0xffffffff00000000ULL)) + rand |= prandom_u32_max((u32)ep_ro); + else +- rand |= prandom_u32(); ++ rand |= get_random_u32(); + #else +- rand = ((u64)prandom_u32() << 32 | prandom_u32()) % ep_ro; ++ rand = ((u64)get_random_u32() << 32 | get_random_u32()) % ep_ro; + #endif + } + +diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c +index bb573827c5..67962fa67a 100644 +--- a/lustre/osd-ldiskfs/osd_handler.c ++++ b/lustre/osd-ldiskfs/osd_handler.c +@@ -910,7 +910,7 @@ struct osd_check_lmv_buf { + * \retval -ve for failure + */ + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_stripe_dir_filldir(struct dir_context *buf, ++static FILLDIR_TYPE do_osd_stripe_dir_filldir(struct dir_context *buf, + #else + static int osd_stripe_dir_filldir(void *buf, + #endif +@@ -950,6 +950,8 @@ static int osd_stripe_dir_filldir(void *buf, + return 1; + } + ++WRAP_FILLDIR_FN(do_, osd_stripe_dir_filldir) ++ + /* + * When lookup item under striped directory, we need to locate the master + * MDT-object of the striped directory firstly, then the client will send +@@ -6961,7 +6963,7 @@ struct osd_filldir_cbs { + * \retval 1 on buffer full + */ + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ldiskfs_filldir(struct dir_context *ctx, ++static FILLDIR_TYPE do_osd_ldiskfs_filldir(struct dir_context *ctx, + #else + static int osd_ldiskfs_filldir(void *ctx, + #endif +@@ -7033,6 +7035,8 @@ static int osd_ldiskfs_filldir(void *ctx, + RETURN(0); + } + ++WRAP_FILLDIR_FN(do_, osd_ldiskfs_filldir) ++ + /** + * Calls ->iterate*() to load a directory entry at a time + * and stored it in iterator's in-memory data structure. +diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h +index 1ee407e1f3..c783d3b923 100644 +--- a/lustre/osd-ldiskfs/osd_internal.h ++++ b/lustre/osd-ldiskfs/osd_internal.h +@@ -1727,4 +1727,22 @@ static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw) + return false; + } + ++#ifdef HAVE_FILLDIR_USE_CTX_RETURN_BOOL ++#define WRAP_FILLDIR_FN(prefix, fill_fn) \ ++static bool fill_fn(struct dir_context *buf, const char *name, int namelen, \ ++ loff_t offset, __u64 ino, unsigned int d_type) \ ++{ \ ++ return !prefix##fill_fn(buf, name, namelen, offset, ino, d_type); \ ++} ++#elif defined(HAVE_FILLDIR_USE_CTX) ++#define WRAP_FILLDIR_FN(prefix, fill_fn) \ ++static int fill_fn(struct dir_context *buf, const char *name, int namelen, \ ++ loff_t offset, __u64 ino, unsigned int d_type) \ ++{ \ ++ return prefix##fill_fn(buf, name, namelen, offset, ino, d_type); \ ++} ++#else ++#define WRAP_FILLDIR_FN(prefix, fill_fn) ++#endif ++ + #endif /* _OSD_INTERNAL_H */ +diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c +index 8c400ed170..ceee333fe3 100644 +--- a/lustre/osd-ldiskfs/osd_scrub.c ++++ b/lustre/osd-ldiskfs/osd_scrub.c +@@ -1360,27 +1360,30 @@ typedef int (*scandir_t)(struct osd_thread_info *, struct osd_device *, + struct dentry *, filldir_t filldir); + + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ios_varfid_fill(struct dir_context *buf, const char *name, +- int namelen, loff_t offset, __u64 ino, +- unsigned d_type); +-static int osd_ios_lf_fill(struct dir_context *buf, const char *name, +- int namelen, loff_t offset, __u64 ino, +- unsigned d_type); +-static int osd_ios_dl_fill(struct dir_context *buf, const char *name, +- int namelen, loff_t offset, __u64 ino, +- unsigned d_type); +-static int osd_ios_uld_fill(struct dir_context *buf, const char *name, +- int namelen, loff_t offset, __u64 ino, +- unsigned d_type); ++static FILLDIR_TYPE ++osd_ios_varfid_fill(struct dir_context *buf, const char *name, int namelen, ++ loff_t offset, __u64 ino, unsigned int d_type); ++ ++static FILLDIR_TYPE ++osd_ios_lf_fill(struct dir_context *buf, const char *name, int namelen, ++ loff_t offset, __u64 ino, unsigned int d_type); ++ ++static FILLDIR_TYPE ++osd_ios_dl_fill(struct dir_context *buf, const char *name, int namelen, ++ loff_t offset, __u64 ino, unsigned int d_type); ++ ++static FILLDIR_TYPE ++osd_ios_uld_fill(struct dir_context *buf, const char *name, int namelen, ++ loff_t offset, __u64 ino, unsigned int d_type); + #else + static int osd_ios_varfid_fill(void *buf, const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type); ++ loff_t offset, __u64 ino, unsigned int d_type); + static int osd_ios_lf_fill(void *buf, const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type); ++ loff_t offset, __u64 ino, unsigned int d_type); + static int osd_ios_dl_fill(void *buf, const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type); ++ loff_t offset, __u64 ino, unsigned int d_type); + static int osd_ios_uld_fill(void *buf, const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type); ++ loff_t offset, __u64 ino, unsigned int d_type); + #endif + + static int +@@ -2009,12 +2012,12 @@ osd_ios_scan_one(struct osd_thread_info *info, struct osd_device *dev, + * or filter_fid_18_23), move them back to its proper /O//d. + */ + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ios_lf_fill(struct dir_context *buf, ++static FILLDIR_TYPE do_osd_ios_lf_fill(struct dir_context *buf, + #else + static int osd_ios_lf_fill(void *buf, + #endif + const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type) ++ loff_t offset, __u64 ino, unsigned int d_type) + { + struct osd_ios_filldir_buf *fill_buf = + (struct osd_ios_filldir_buf *)buf; +@@ -2089,14 +2092,15 @@ put: + /* skip the failure to make the scanning to continue. */ + return 0; + } ++WRAP_FILLDIR_FN(do_, osd_ios_lf_fill) + + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ios_varfid_fill(struct dir_context *buf, ++static FILLDIR_TYPE do_osd_ios_varfid_fill(struct dir_context *buf, + #else + static int osd_ios_varfid_fill(void *buf, + #endif + const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type) ++ loff_t offset, __u64 ino, unsigned int d_type) + { + struct osd_ios_filldir_buf *fill_buf = + (struct osd_ios_filldir_buf *)buf; +@@ -2125,14 +2129,15 @@ static int osd_ios_varfid_fill(void *buf, + + RETURN(rc); + } ++WRAP_FILLDIR_FN(do_, osd_ios_varfid_fill) + + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ios_dl_fill(struct dir_context *buf, ++static FILLDIR_TYPE do_osd_ios_dl_fill(struct dir_context *buf, + #else + static int osd_ios_dl_fill(void *buf, + #endif + const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type) ++ loff_t offset, __u64 ino, unsigned int d_type) + { + struct osd_ios_filldir_buf *fill_buf = + (struct osd_ios_filldir_buf *)buf; +@@ -2170,14 +2175,15 @@ static int osd_ios_dl_fill(void *buf, + + RETURN(rc); + } ++WRAP_FILLDIR_FN(do_, osd_ios_dl_fill) + + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ios_uld_fill(struct dir_context *buf, ++static FILLDIR_TYPE do_osd_ios_uld_fill(struct dir_context *buf, + #else + static int osd_ios_uld_fill(void *buf, + #endif + const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type) ++ loff_t offset, __u64 ino, unsigned int d_type) + { + struct osd_ios_filldir_buf *fill_buf = + (struct osd_ios_filldir_buf *)buf; +@@ -2209,14 +2215,15 @@ static int osd_ios_uld_fill(void *buf, + + RETURN(rc); + } ++WRAP_FILLDIR_FN(do_, osd_ios_uld_fill) + + #ifdef HAVE_FILLDIR_USE_CTX +-static int osd_ios_root_fill(struct dir_context *buf, ++static FILLDIR_TYPE do_osd_ios_root_fill(struct dir_context *buf, + #else + static int osd_ios_root_fill(void *buf, + #endif + const char *name, int namelen, +- loff_t offset, __u64 ino, unsigned d_type) ++ loff_t offset, __u64 ino, unsigned int d_type) + { + struct osd_ios_filldir_buf *fill_buf = + (struct osd_ios_filldir_buf *)buf; +@@ -2262,6 +2269,8 @@ out_put: + RETURN(rc); + } + ++WRAP_FILLDIR_FN(do_, osd_ios_root_fill) ++ + static int + osd_ios_general_scan(struct osd_thread_info *info, struct osd_device *dev, + struct dentry *dentry, filldir_t filldir) +-- +2.39.1 + diff --git a/0004-LU-16662-autoconf-fix-configure-test-compile-for-CON.patch b/0004-LU-16662-autoconf-fix-configure-test-compile-for-CON.patch new file mode 100644 index 0000000000000000000000000000000000000000..832c365d7d4a0ecfe89480b1e7b5fe68cf70c88a --- /dev/null +++ b/0004-LU-16662-autoconf-fix-configure-test-compile-for-CON.patch @@ -0,0 +1,70 @@ +From 240d04b6a55bff2e4dfc0e1de6ce2bbfa85e9d70 Mon Sep 17 00:00:00 2001 +From: Xinliang Liu +Date: Fri, 24 Mar 2023 07:16:10 +0000 +Subject: [PATCH 4/5] LU-16662 autoconf: fix configure test compile for + CONFIG_KEYS + +This fixes below configure error on Linux v5.19+: +$ ./configure --disable-server +... +checking whether to enable gss keyring backend... yes +checking if Linux kernel was built with CONFIG_KEYS in or as module... +no +configure: WARNING: GSS keyring backend requires that CONFIG_KEYS be +enabled in your kernel. +checking for keyctl_search in -lkeyutils... yes +configure: error: Cannot enable gss_keyring. See above for details. +$ grep CONFIG_KEYS -rn /boot/config-* +6884:CONFIG_KEYS=y + +For in-tree IB support and without passing Linux src path when run +./configure, the LINUX_OBJ maybe just a soft link to O2IBPATH, they +are pointing to the same dir. E.g.: +O2IBPATH='/usr/src/kernels/6.1.8-3.0.0.7.oe1.aarch64' +LINUX_OBJ='/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build' +$ ls -l /lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build +lrwxrwxrwx 1 root root 42 Feb 7 00:00 +/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build -> +/usr/src/kernels/6.1.8-3.0.0.7.oe1.aarch64 +In this case, current configure will put kernel's Module.symvers to +variable KBUILD_EXTRA_SYMBOLS. This should be avoided after kernel +v5.19 which contains commit "b8422711080f modpost: make multiple export +error". This making multiple export symbol as an error from a warning +which can be seen in the config.log: +... +ERROR: modpost: vmlinux: 'init_uts_ns' exported twice. Previous export +was in vmlinux +... + +Test-Parameters: trivial +Change-Id: I35295b3acc7fffb93716362f5d8c659eb922afcb +Signed-off-by: Xinliang Liu +--- + lnet/autoconf/lustre-lnet.m4 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 +index 6aff70afd5..8fe90cbdd7 100644 +--- a/lnet/autoconf/lustre-lnet.m4 ++++ b/lnet/autoconf/lustre-lnet.m4 +@@ -245,7 +245,7 @@ AS_IF([test $ENABLEO2IB = "no"], [ + O2IB_SYMVER=$LINUX_OBJ/Module.symvers + fi + if test -n "$O2IB_SYMVER"; then +- if test "$O2IB_SYMVER" != "$LINUX_OBJ/Module.symvers"; then ++ if test !"$O2IB_SYMVER" -ef "$LINUX_OBJ/Module.symvers"; then + AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path O2IB]) + EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER" + AC_SUBST(EXTRA_SYMBOLS) +@@ -286,7 +286,7 @@ AC_SUBST(ENABLEO2IB) + + AS_IF([test $ENABLEO2IB != "no"], [ + EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE" +- if test $O2IBPATH != $LINUX_OBJ; then ++ if test ! $O2IBPATH -ef $LINUX_OBJ; then + KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS $O2IBPATH/Module.symvers" + fi + +-- +2.39.1 + diff --git a/0005-lustre.spec.in-Add-gcc-option-Wno-stringop-overflow.patch b/0005-lustre.spec.in-Add-gcc-option-Wno-stringop-overflow.patch new file mode 100644 index 0000000000000000000000000000000000000000..111525093da25cf16a507e2efa8a427d6ea2276e --- /dev/null +++ b/0005-lustre.spec.in-Add-gcc-option-Wno-stringop-overflow.patch @@ -0,0 +1,28 @@ +From f4fa472941943b9d1b74df40a31c8d697230fa93 Mon Sep 17 00:00:00 2001 +From: Xinliang Liu +Date: Fri, 24 Mar 2023 08:21:06 +0000 +Subject: [PATCH 5/5] lustre.spec.in: Add gcc option -Wno-stringop-overflow + +See openEuler gcc bug: https://gitee.com/openeuler/gcc/issues/I5XMD0 + +Signed-off-by: Xinliang Liu +--- + lustre.spec.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lustre.spec.in b/lustre.spec.in +index 653bc1e291..7b544c23e4 100644 +--- a/lustre.spec.in ++++ b/lustre.spec.in +@@ -476,7 +476,7 @@ export UTILS_CFLAGS="${UTILS_CFLAGS} -D__SANE_USERSPACE_TYPES__=1" + # Disable any hardening or annotation since this doesn't make sense for + # kernel code, and reset "optflags" so that the vendor's overzealous flags don't + # create build failures. +-%define optflags -g -O2 -Werror ++%define optflags -g -O2 -Werror -Wno-stringop-overflow + %undefine _annotated_build + %undefine _hardened_build + +-- +2.39.1 + diff --git a/2.15.54.tar.gz b/2.15.54.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..193ff91ac59728c82e238e906b7f8e16e77ddc85 Binary files /dev/null and b/2.15.54.tar.gz differ diff --git a/kmp-lustre-osd-ldiskfs.files b/kmp-lustre-osd-ldiskfs.files new file mode 100644 index 0000000000000000000000000000000000000000..47bcee182499932c4c7641f957c4088fea795651 --- /dev/null +++ b/kmp-lustre-osd-ldiskfs.files @@ -0,0 +1,3 @@ +%defattr(-,root,root) +%{modules_fs_path}/%{lustre_name}-osd-ldiskfs/fs/ldiskfs.ko +%{modules_fs_path}/%{lustre_name}-osd-ldiskfs/fs/osd_ldiskfs.ko diff --git a/kmp-lustre-osd-ldiskfs.preamble b/kmp-lustre-osd-ldiskfs.preamble new file mode 100644 index 0000000000000000000000000000000000000000..cdd8a122e85ba6af1adbe00dac7b397e77686eed --- /dev/null +++ b/kmp-lustre-osd-ldiskfs.preamble @@ -0,0 +1,10 @@ +License: GPL-2.0-only +Requires: %{requires_kmod_name} = %{requires_kmod_version} +Requires: ldiskfsprogs >= 1.44.3.wc1 +Requires: %{name}-osd-ldiskfs-mount = %{version} +Provides: %{name}-osd = %{version} +Provides: lustre-osd = %{version} +Obsoletes: %{name}-ldiskfs < %{version} +Obsoletes: %{name}-osd-ldiskfs < %{version} +Obsoletes: lustre-ldiskfs < %{version} +Obsoletes: lustre-osd-ldiskfs < %{version} diff --git a/kmp-lustre-osd-zfs.files b/kmp-lustre-osd-zfs.files new file mode 100644 index 0000000000000000000000000000000000000000..0ac2677dd8fb8a3533b03c258b7a104ee738e6bf --- /dev/null +++ b/kmp-lustre-osd-zfs.files @@ -0,0 +1,2 @@ +%defattr(-,root,root) +%{modules_fs_path}/%{lustre_name}-osd-zfs/fs/osd_zfs.ko diff --git a/kmp-lustre-osd-zfs.preamble b/kmp-lustre-osd-zfs.preamble new file mode 100644 index 0000000000000000000000000000000000000000..339ed9bbe0514a467a30c4396347c588a93746c1 --- /dev/null +++ b/kmp-lustre-osd-zfs.preamble @@ -0,0 +1,5 @@ +Summary: Lustre osd-zfs feature support +License: GPL-2.0-only +Requires: %{name}-osd-zfs-mount = %{version} +Provides: %{name}-osd = %{version} +Obsoletes: %{name}-osd-zfs < %{version} diff --git a/kmp-lustre-tests.files b/kmp-lustre-tests.files new file mode 100644 index 0000000000000000000000000000000000000000..f62b46f963be3f4721e163731ed8f840ee63a36f --- /dev/null +++ b/kmp-lustre-tests.files @@ -0,0 +1 @@ +%{modules_fs_path}/%{lustre_name}-tests/fs/llog_test.ko diff --git a/kmp-lustre.files b/kmp-lustre.files new file mode 100644 index 0000000000000000000000000000000000000000..62e39d0d0fba71dd9023fc77084d21bd429c49b9 --- /dev/null +++ b/kmp-lustre.files @@ -0,0 +1,5 @@ +%defattr(-,root,root) +%{modules_fs_path}/%{lustre_name}/* +%doc COPYING +%doc ChangeLog-lustre +%doc ChangeLog-lnet diff --git a/kmp-lustre.preamble b/kmp-lustre.preamble new file mode 100644 index 0000000000000000000000000000000000000000..9224573471ae63e94ad8c018921b52e947b9fcdd --- /dev/null +++ b/kmp-lustre.preamble @@ -0,0 +1,2 @@ +Obsoletes: %{name}-modules < %{version} +License: GPL-2.0-only diff --git a/lustre.spec b/lustre.spec new file mode 100644 index 0000000000000000000000000000000000000000..14db31a6cc93f8bae8aecac9681207efbf4b4e6a --- /dev/null +++ b/lustre.spec @@ -0,0 +1,880 @@ +# lustre.spec + +# Declare rpmbuild --with/--without parameters +%bcond_with servers +%bcond_without ldiskfs +%bcond_with zfs +%bcond_without lustre_tests +%bcond_without lustre_utils +%bcond_without lustre_iokit +%bcond_without lustre_modules +%bcond_with snmp +%bcond_with gss +%bcond_with gss_keyring +%bcond_without manpages +%bcond_without shared +%bcond_without static +%bcond_with systemd +%bcond_with mofed +%bcond_with mpi +%bcond_with kabi + +# LUTF Turn off brp-python-precompile script as we don't want the python files +# to be compiled on installation +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') + +# By default both gss and gss keyring are disabled. +# gss keyring requires the gss core. If the builder +# request gss_keyring we must enable gss core even if +# the builder attempts to disable gss. +%if %{with gss_keyring} + %define with_gss 1 +%endif + +%if %{without servers} + # --without servers overrides --with {ldiskfs|zfs} + # so undefine the internal variables set by bcond_* + %undefine with_ldiskfs + %undefine with_zfs +%endif + +%if %{without shared} && %{without static} +# need exit to stop build because error only displays a message +%{error: you can't disable both library types} +%{exit 1} +%endif + +# lustre_tests depends on lustre_utils +%if %{without lustre_utils} +%undefine with_lustre_tests +%endif + +%{!?version: %global version 2.15.54} +# if you want a custom kernel version set it variable with $ver.$arch +%{!?kver: %global kver %(rpm -q --qf '%%{VERSION}-%%{RELEASE}.%%{ARCH}' `rpm -q kernel-devel | sort -r|head -n 1`)} +# cut epoch for kmodtool +%define _kver %(echo %{kver} | sed -e 's/^[0-9]*://') +# trust version from kdir - but it can lost 'epoch' +%if %{defined kdir} + %define _take_kver 1 +%endif +%if %{defined kobjdir} + %define _take_kobj 1 +%endif +%{!?kdir: %global kdir /lib/modules/%{_kver}/source} +%{!?kobjdir: %global kobjdir %(if [ "%{kdir}" = "/lib/modules/%{_kver}/source" ]; then echo "/lib/modules/%{_kver}/build"; else echo "%{kdir}"; fi)} + +%if 0%{?suse_version} >= 1310 && %{defined _take_kobj} + %global _flavor %(echo %{_kver} | sed -e 's/^.*-//') +%else + %global _flavor default +%endif + +%if %{defined _take_kver} +# as an alternative to this implementation we could simply "make -C $kdir kernelversion" +%global kver %(files="include/generated/utsrelease.h include/linux/utsrelease.h include/linux/version.h"; for f in $files; do if test -r %{kobjdir}/$f && grep UTS_RELEASE %{kobjdir}/$f >/dev/null; then sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' %{kobjdir}/$f; break; fi; done) +%define _kver %kver +%endif + +# We set this because kernel_module_package has its own method of identifying +# which kernel to build against, and it is unlikely that its decision will +# match with Lustre's method of selecting which kernel to build against. +# By setting this variable, we override kernel_module_package's kernel +# selection with our selection. +# kmodtool failed to take a version if epoch set +%global kernel_version %_kver + +# in order to get kernel symset and/or kernel module dependencies into +# the RPM, in order to support weak-modules, the internal dependency gen- +# erator needs to be disabled +# this is done with (reduce the double % down to a single %): +# +# %%global _use_internal_dependency_generator 0 +# +# on SLES10, /usr/lib/rpm/macros already sets this, so no harm in also +# defining it here (until Suse changes their mind) +# +# on RHEL5, however, we do need to explicitly disable the internal dep- +# endency generator and allow the external one be used +# but since RedHat's kABI is only a subset of the total kernel ABI, it +# doesn't include all of the symbols we (or OFED for that matter) need +# until RedHat includes all of the symbols we need in their symsets we +# cannot support weak-modules +# we did e-mail the maintainer of all of this stuff @redhat but got no +# response from them +#%%global _use_internal_dependency_generator 0 + +# Set the package name prefix +%if %{undefined lustre_name} + %if %{with servers} + %global lustre_name lustre + %else + %global lustre_name lustre-client + %endif +%endif + +%if %{with lustre_modules} +%if %{undefined kmoddir} + %if %{defined kernel_module_package_moddir} + %global kmoddir %{kernel_module_package_moddir} + %else + %if %{defined suse_kernel_module_package} + %global kmoddir updates + %else + %global kmoddir extra + %endif + %endif +%endif + +%global modules_fs_path /lib/modules/%{_kver}/%{kmoddir} +# requires want to set a version including epoch +%global krequires %(echo %{kver} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/[-.]ppc64$//' -e 's/\.aarch64$//' -e 's/-default$//' -e 's/-%{_flavor}//') + +%if "%{_vendor}" == "redhat" || "%{_vendor}" == "fedora" || "%{_vendor}" == "openEuler" + %global requires_kmod_name kmod-%{lustre_name} + %global requires_kmod_osd_zfs_name kmod-%{lustre_name}-osd-zfs + %if %{with lustre_tests} + %global requires_kmod_tests_name kmod-%{lustre_name}-tests + %endif + %global requires_kmod_version %{version} +#for Suse +%else + %global requires_kmod_name %{lustre_name}-kmp + %global requires_kmod_osd_zfs_name %{lustre_name}-osd-zfs-kmp + %if %{with lustre_tests} + %global requires_kmod_tests_name %{lustre_name}-tests-kmp + %endif + %if 0%{?suse_version} >= 1200 + %global requires_kmod_version %{version}_k%(echo %{krequires} | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/;') + %else + %global requires_kmod_version %{version}_%(echo %{krequires} | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/;') + %endif +%endif +%endif + +# RHEL >= 7 comes with systemd +%if 0%{?rhel} >= 7 +%define with_systemd 1 +%endif + +# Fedora >= 15 comes with systemd, but only >= 18 has +# the proper macros +%if 0%{?fedora} >= 18 +%define with_systemd 1 +%endif + +# opensuse >= 12.1 comes with systemd, but only >= 13.1 +# has the proper macros +%if 0%{?suse_version} >= 1310 +%define with_systemd 1 +%endif + +# openEuler comes with systemd +%if "%{_vendor}" == "openEuler" +%define with_systemd 1 +%endif + +%{!?mpi_name: %global mpi_name openmpi} + +Summary: Lustre File System +Name: %{lustre_name} +Version: 2.15.54 +Release: 1%{?dist} +License: GPL-2.0-only AND LGPL-2.1-or-later +Group: System Environment/Kernel +Source: https://github.com/lustre/lustre-release/archive/refs/tags/%{version}.tar.gz +Source1: kmp-lustre.preamble +Source2: kmp-lustre.files +Source3: kmp-lustre-osd-ldiskfs.preamble +Source4: kmp-lustre-osd-ldiskfs.files +Source5: kmp-lustre-osd-zfs.preamble +Source6: kmp-lustre-osd-zfs.files +Source7: kmp-lustre-tests.files +URL: https://wiki.whamcloud.com/ +BuildRoot: %{_tmppath}/lustre-%{version}-root + +# patches +Patch1: 0001-LU-16327-llite-read_folio-release_folio-filler_t.patch +Patch2: 0002-LU-16328-llite-Linux-6.0-migrate_folio-vfs_setxattr.patch +Patch3: 0003-LU-16351-llite-Linux-6.1-prandom-folios_contig-vma_i.patch +Patch4: 0004-LU-16662-autoconf-fix-configure-test-compile-for-CON.patch +Patch5: 0005-lustre.spec.in-Add-gcc-option-Wno-stringop-overflow.patch + +%if %{with lustre_modules} +Requires: %{requires_kmod_name} = %{requires_kmod_version} +%endif +%if %{with lustre_tests_lutf} +Requires: python3 >= 3.6.0 +BuildRequires: python3-devel >= 3.6.0, swig +%endif +BuildRequires: libtool libyaml-devel zlib-devel libnl3-devel flex bison +%if "%{_vendor}" == "redhat" +BuildRequires: redhat-rpm-config +BuildRequires: pkgconfig +%else +%if "%{_vendor}" == "openEuler" +BuildRequires: openEuler-rpm-config +%endif +BuildRequires: pkg-config +%endif +%if %{with gss} +BuildRequires: krb5-devel openssl-devel +%endif +%if %{with servers} +Requires: %{name}-osd +Requires: %{name}-osd-mount +Obsoletes: lustre-server < %{version} +Provides: lustre-server = %{version}-%{release} +%endif +Obsoletes: lustre-client < %{version} +Provides: lustre-client = %{version}-%{release} +%if "%{_vendor}" == "redhat" || "%{_vendor}" == "fedora" || "%{_vendor}" == "openEuler" +#suse don't support selinux +BuildRequires: libselinux-devel +%endif +%if %{with lustre_modules} +%if %{with mofed} +BuildRequires: mlnx-ofa_kernel-devel +%if "%{_vendor}" == "redhat" || "%{_vendor}" == "openEuler" +Requires: kmod-mlnx-ofa_kernel +%else +Requires: mlnx-ofa_kernel-kmp +%endif +%endif +%if 0%{?rhel} >= 8 || "%{_vendor}" == "openEuler" +BuildRequires: kernel-rpm-macros +%endif +%if 0%{?suse_version} >= 1530 +BuildRequires: rpm-build >= 4.14.3 +%endif +BuildRequires: %kernel_module_package_buildreqs +# need to provide a /usr/lib/${uname -r)/build dir +BuildRequires: kernel +%if "%{_vendor}" == "redhat" +%if %{with kabi} +BuildRequires: kernel-abi-whitelists +%endif +%endif +%endif + +%if %{with systemd} +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +BuildRequires: systemd +%endif + +%description +Userspace tools and files for the Lustre file system. + +%if %{with lustre_modules} +%if 0%{?rhel} == 7 +# until we have achieved full kABI compatibility we need to +# restrict the kernel range that can be used to the kernel +# version from the RHEL minor release +# this is supposed to be done for kmods automatically but +# RHBZ#1467319 seems to be getting in the way +# this is true for el7.0 through el7.4 +%define preamble %{expand:%( +TMPFILE=`mktemp` +cat %{SOURCE1} > $TMPFILE +kver=%{kernel_version} +linuxversion=${kver%%%%-*} +linuxrelease=${kver##*-} +kabiminor=${linuxrelease%%%%.*} +echo "Requires: kernel < $linuxversion-$((kabiminor+1)), kernel >= $linuxversion-$((kabiminor))" >> $TMPFILE +echo $TMPFILE +)} +%else +%define preamble %{SOURCE1} +%endif +%kernel_module_package -n %{name} -p %preamble -f %SOURCE2 %{_flavor} + +%if %{with ldiskfs} +%kernel_module_package -n %{name}-osd-ldiskfs -p %SOURCE3 -f %SOURCE4 %{_flavor} +%if %{with lustre_utils} +%package osd-ldiskfs-mount +Summary: osd-ldiskfs-mount contains mount's ldiskfs specific dso. +BuildRequires: e2fsprogs-devel >= 1.44.3 libmount-devel +Requires: ldiskfsprogs > 1.45.6 libmount +Provides: lustre-osd-mount = %{version} +Provides: %{name}-osd-mount = %{version} +Obsoletes: %{name}-osd-mount < %{version} +Obsoletes: lustre-osd-mount < %{version} +Group: System Environment/Kernel + +%description osd-ldiskfs-mount +LDISKFS hooks for mount/mkfs into a dynamic library. + +# with lustre_utils +%endif +# with ldiskfs +%endif + +%if %{with zfs} +%kernel_module_package -n %{name}-osd-zfs -p %SOURCE5 -f %SOURCE6 %{_flavor} +%if %{with lustre_utils} +%package osd-zfs-mount +Summary: osd-zfs-mount contains mount's zfs specific dso. +BuildRequires: libmount-devel +Requires: libmount +Provides: %{name}-osd-mount = %{version} +Obsoletes: lustre-osd-mount < %{version} +# Tests also require zpool from zfs package: +Requires: zfs +Requires: %{requires_kmod_osd_zfs_name} +Group: System Environment/Kernel + +%description osd-zfs-mount +ZFS hooks for mount/mkfs into a dynamic library. + +# with lustre_utils +%endif +# with zfs +%endif +# with lustre_modules +%endif + +%if %{with servers} +%package resource-agents +Summary: HA Resuable Cluster Resource Scripts for Lustre +Group: System Environment/Base +Requires: %{name} +Requires: resource-agents + +%description resource-agents +A set of scripts to operate Lustre resources in a High Availablity +environment for both Pacemaker and rgmanager. +%endif + +%package devel +Summary: Lustre include headers +Group: Development/Kernel +Provides: lustre-devel = %{version} +Requires: %{lustre_name} = %{version} +%if %{with lustre_modules} +Requires: %{requires_kmod_name} = %{requires_kmod_version} +%endif + +%description devel +This package contains the header files needed for building additional +applications against the Lustre / LNet utilities libraries. + +:> lustre-devel.files + +%if %{with lustre_tests} +%package tests +Summary: Lustre testing framework +Group: System Environment/Kernel +Provides: %{name}-tests = %{version} +%if %{with lustre_iokit} +Requires: %{name} = %{version}, lustre-iokit +%else +Requires: %{name} = %{version} +%endif +Requires: lustre-devel = %{version} +%if 0%{?rhel} >= 8 || 0%{?suse_version} >= 1500 || 0%{?openEuler} +Requires: python3 >= 3.6.0, python3-PyYAML +%endif +%if %{with lustre_modules} +Requires: %{requires_kmod_name} = %{requires_kmod_version} +Requires: %{requires_kmod_tests_name} = %{requires_kmod_version} +%endif +%if %{with lustre_tests_lutf} +Requires: python3 >= 3.6.0 +%endif +Requires: attr, rsync, perl, lsof, /usr/bin/getconf +%if %{with mpi} +%if "%{mpi_name}" == "mpich" +BuildRequires: mpich-devel +%endif +%if "%{mpi_name}" == "openmpi" +%if "%{_vendor}" == "redhat" || "%{_vendor}" == "openEuler" || 0%{?suse_version} < 1500 +BuildRequires: openmpi-devel +%else +BuildRequires: openmpi2-devel +%endif +# openmpi +%endif +# mpi +%endif + +%description tests +This package contains a set of test binaries and scripts that are intended +to be used by the Lustre testing framework. + +%if %{with lustre_modules} +%kernel_module_package -n %{name}-tests -f %SOURCE7 %{_flavor} +%endif +%endif + +%if %{with lustre_iokit} +%package -n lustre-iokit +Summary: The Lustre IO-Kit is a collection of benchmark tools for a cluster with the Lustre file system. +Group: Applications/System +Requires: python3, sg3_utils + +%description -n lustre-iokit +This package includes five tools: +sgpdd-survey: +A test of the 'bare metal' performance, bypassing as much of the kernel as we can. Uses the sgp_dd utility. + +obdfilter-survey +This survey can be run in 3 modes to test disk I/O including the filesystem, +network I/O, and disk I/O via the network. The script does sequential I/O +with varying numbers of threads and objects (files) by using lctl::test_brw +to drive the echo_client connected to local or remote obdfilter instances, +or remote obdecho instances. + +ost-survey +This survey tests the client-to-disk performance of individual OSTs, and +ranks then for comparison. + +stats-collect +This script will collect IO stats on a defined set of nodes. + +ior-survey: +A script to run the IOR benchmark. The latest version can be downloaded from +http://www.llnl.gov/asci/purple/benchmarks/limited/ior/ + +mds-survey: +This survey tests the local metadata performance using the echo_client to drive +the MDD layer to perform operations. It is run with multiple threads (to +simulate MDT service threads) locally on the MDS node, and does not need Lustre +clients in order to run +%endif + +%if 0%{?suse_version} +%debug_package +%endif +%prep +%autosetup -n lustre-release-%{version} -p1 +ln lustre/ChangeLog ChangeLog-lustre +ln lnet/ChangeLog ChangeLog-lnet + +%build +# Set an explicit path to our Linux tree, if we can. +#cd $RPM_BUILD_DIR/lustre-%{version} +sh autogen.sh + +# Store the CFLAGS and LDFLAGS that would normally be used in the UTILS_CFLAGS +# and UTILS_LDFLAGS environment variables so that we use can them when compiling +# the user-space code in lustre/utils and lnet/utils. As of RHEL 8.0, the +# __global_* variants are deprecated in favour of build_cflags, etc. If neither +# style is available (e.g. on SLES), then these just end up as empty strings. +export UTILS_CFLAGS="%{?build_cflags:%{build_cflags}}%{!?build_cflags:%{?__global_cflags:%{__global_cflags}}}" +export UTILS_LDFLAGS="%{?build_ldflags:%{build_ldflags}}%{!?build_ldflags:%{?__global_ldflags:%{__global_ldflags}}}" + +# RHEL7 on PPC64 needs __SANE_USERSPACE_TYPES__ defined so that __s64 and __u64 +# are presented to user-land as long long instead of long long. Without this it +# will fail the format check whenever such a variable is printed. +%if 0%{?rhel} +%ifarch ppc64 +export UTILS_CFLAGS="${UTILS_CFLAGS} -D__SANE_USERSPACE_TYPES__=1" +%endif +%endif + +# Disable any hardening or annotation since this doesn't make sense for +# kernel code, and reset "optflags" so that the vendor's overzealous flags don't +# create build failures. +%define optflags -g -O2 -Werror -Wno-stringop-overflow +%undefine _annotated_build +%undefine _hardened_build + +CONFIGURE_ARGS="%{?configure_args}" +if [ -n "$CONFIGURE_ARGS" ]; then + # make sure %%kdir and %%kobjdir are not in the configure arguments + CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//') + CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux-obj=[^ ][^ ]* \?//') + # remove --with-kmp-moddir from configure arguments, + # it will be set --with-kmp-moddir=%%kmoddir + CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-kmp-moddir=[^ ][^ ]* \?//') + # remove env variables from config cache built by initial configure, + # and create dedicated cache in temporary build directory + if [ -f "$CONFIG_CACHE_FILE" ]; then + TMP_CONFIG_CACHE="$(mktemp --tmpdir newconfig-XXXXXXXX.cache)" + sed -e "/ac_cv_env/d" \ + -e "/am_cv_CC_dependencies_compiler_type/d" \ + -e "/lb_cv_mpi_tests/d" \ + "$CONFIG_CACHE_FILE" > $TMP_CONFIG_CACHE + CONFIGURE_ARGS="$CONFIGURE_ARGS --cache-file=$TMP_CONFIG_CACHE" + fi +fi + +# we need to eval "configure" because $CONFIGURE_ARGS could have a quoted +# string in it which we don't want word splitted by the shell +# also remove (build|host|target) options because they will be specified +# inside $CONFIGURE_ARGS +# kmod tools/scripts require "name" directory with kernel modules + +%if 0%{?rhel} >= 9 +%define _configure eval ./configure +%define eval_configure %configure +%else +%define eval_configure %(echo -n '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g') +%endif + +%if %{with mpi} +%if "%{mpi_name}" == "mpich" +%{?_mpich_load} +%endif +%if "%{mpi_name}" == "openmpi" +%{?_openmpi_load} +%endif +# mpi +%endif + +%if %{with mofed} + o2ib_path=$(find /usr/src/ofa_kernel/ -type d -name ofed_scripts | xargs dirname) + if [ -z "$o2ib_path" ]; then + echo "ERROR: could not find OFED devel headers" + exit 1 + fi + if [ $(echo $o2ib_path | wc -w) -ge 2 ]; then + echo "ERROR: multiple OFED versions installed" + exit 1 + fi +%endif + +%eval_configure $CONFIGURE_ARGS \ + %{?with_lustre_tests:--enable-tests}%{!?with_lustre_tests:--disable-tests} \ + %{?with_lustre_utils:--enable-utils}%{!?with_lustre_utils:--disable-utils} \ + %{?with_lustre_modules:--enable-modules}%{!?with_lustre_modules:--disable-modules} \ + %{!?with_shared:--disable-shared} \ + %{!?with_static:--disable-static} \ + %{!?with_lustre_iokit:--disable-iokit} \ + %{!?with_ldiskfs:--disable-ldiskfs} \ + %{!?with_servers:--disable-server} \ + %{!?with_zfs:--without-zfs} \ + %{!?with_snmp:--disable-snmp} \ + %{!?with_gss:--disable-gss} \ + %{!?with_gss_keyring:--disable-gss-keyring} \ + %{!?with_manpages:--disable-manpages} \ + %{!?with_systemd:--with-systemdsystemunitdir=no} \ + %{?with_systemd:--with-systemdsystemunitdir=%{_unitdir}} \ + %{?with_mofed:--with-o2ib=$o2ib_path} \ + --with-linux=%{kdir} \ + --with-linux-obj=%{kobjdir} \ + --with-kmp-moddir=%{kmoddir}/%{name} + +%if %{with servers} +if ! grep -q define[[:space:]]*HAVE_SERVER_SUPPORT config.h 2> /dev/null; then + echo "Error: Server Support configured but not found" + false +fi +%endif + +make %{?_smp_mflags} -s %{?make_args} + +%if %{with mpi} +%if "%{mpi_name}" == "mpich" +%{?_mpich_unload} +%endif +%if "%{mpi_name}" == "openmpi" +%{?_openmpi_unload} +%endif +# mpi +%endif + +%install + +%if %{with mpi} +%if "%{mpi_name}" == "mpich" +%{?_mpich_load} +%endif +%if "%{mpi_name}" == "openmpi" +%{?_openmpi_load} +%endif +# mpi +%endif + +make install DESTDIR=$RPM_BUILD_ROOT + +%if %{with lustre_modules} +# RHEL's kernel_module_path macro expects that all the modules +# in a kmod package will be in modules_fs_path/ +# but Lustre installs all of the modules in a single pass into +# a shared location. Since this is a restriction imposed by +# RHEL, we handle this here in the spec file rather than in +# Lustre's build system. This is not expected to bother SLES's +# kernel_module_path macro. +basemodpath=$RPM_BUILD_ROOT%{modules_fs_path}/%{name} +%if %{with ldiskfs} +mkdir -p $basemodpath-osd-ldiskfs/fs +mv $basemodpath/fs/osd_ldiskfs.ko $basemodpath-osd-ldiskfs/fs/osd_ldiskfs.ko +mv $basemodpath/fs/ldiskfs.ko $basemodpath-osd-ldiskfs/fs/ldiskfs.ko +%endif +%if %{with zfs} +mkdir -p $basemodpath-osd-zfs/fs +mv $basemodpath/fs/osd_zfs.ko $basemodpath-osd-zfs/fs/osd_zfs.ko +%endif +%if %{with lustre_tests} +mkdir -p $basemodpath-tests/fs +mv $basemodpath/fs/llog_test.ko $basemodpath-tests/fs/llog_test.ko +mkdir -p $RPM_BUILD_ROOT%{_libdir}/lustre/tests/kernel/ +mv $basemodpath/fs/kinode.ko $RPM_BUILD_ROOT%{_libdir}/lustre/tests/kernel/ +%endif +%endif + +%if %{without mpi} +if [ -d $RPM_BUILD_ROOT%{_libdir}/openmpi ] ; then + rm -fr $RPM_BUILD_ROOT%{_libdir}/openmpi +fi +if [ -d $RPM_BUILD_ROOT%{_libdir}/mpich ] ; then + rm -fr $RPM_BUILD_ROOT%{_libdir}/mpich +fi +%endif + +:> lustre.files + +%if %{with servers} && %{with lustre_utils} +# The .ha_v2 extension identifies the heartbeat resource agent as using +# legacy syntax. Install a compatibility symlink to avoid conflicts when +# newer-style agents are added. +ln -s Lustre.ha_v2 $RPM_BUILD_ROOT%{_sysconfdir}/ha.d/resource.d/Lustre +echo '%{_sysconfdir}/ha.d/resource.d/Lustre.ha_v2' >>lustre.files +echo '%{_sysconfdir}/ha.d/resource.d/Lustre' >>lustre.files +%endif + +# systemd is on redhat, fedora, and suse +%if %{with systemd} +echo '%{_unitdir}/lnet.service' >>lustre.files +%endif + +%if "%{_vendor}" == "redhat" || "%{_vendor}" == "openEuler" +# The following scripts are Red Hat specific +%if %{with servers} +echo '%{_sysconfdir}/init.d/lustre' >>lustre.files +echo '%{_sysconfdir}/sysconfig/lustre' >>lustre.files +%if %{with gss_keyring} +echo '%{_sysconfdir}/init.d/lsvcgss' >>lustre.files +echo '%config(noreplace) %{_sysconfdir}/sysconfig/lsvcgss' >>lustre.files +%endif +%endif + +%if %{without systemd} +echo '%{_sysconfdir}/init.d/lnet' >>lustre.files +%endif +%endif +%if %{with gss_keyring} +echo '%config(noreplace) %{_sysconfdir}/request-key.d/lgssc.conf' >>lustre.files +%endif + +# fc18 needs 'x' permission for library files +find $RPM_BUILD_ROOT -name \*.so -type f -exec chmod +x {} \; + +rm -f $RPM_BUILD_ROOT%{_libdir}/liblnetconfig.la +%if %{with static} +echo '%attr(-, root, root) %{_libdir}/liblnetconfig.a' >>lustre.files +%endif +%if %{with shared} +echo '%attr(-, root, root) %{_libdir}/liblnetconfig.so' >>lustre-devel.files +echo '%attr(-, root, root) %{_libdir}/liblnetconfig.so.*' >>lustre.files +%endif + +%if %{with ldiskfs} +echo '%{_libdir}/libiam.a' >>lustre.files +%endif + +%if %{with snmp} +mkdir -p $RPM_BUILD_ROOT/%{_libdir}/lustre/snmp +echo '%{_libdir}/lustre/snmp' >>lustre.files +%endif + +%if %{with lustre_utils} +mkdir -p $RPM_BUILD_ROOT/%{_datadir}/lustre +if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre ] ; then + find $RPM_BUILD_ROOT%{_libdir}/lustre -name \*.la -type f -exec rm -f {} \; +fi +%endif + +%if %{with lustre_modules} +# mark modules executable for find-debuginfo.sh +find $RPM_BUILD_ROOT/lib/modules -name \*.ko -type f -exec chmod u+x {} \; +%endif + +rm -f $RPM_BUILD_ROOT%{_libdir}/liblustreapi.la + +%if %{with lustre_tests} +:> lustre-tests.files +%if %{with mpi} +%if "%{mpi_name}" == "mpich" +%{?_mpich_load} +%endif +%if "%{mpi_name}" == "openmpi" +%{?_openmpi_load} +%endif +# mpi +%endif +echo '%{_libdir}/lustre/tests/*' >>lustre-tests.files +echo '%{_bindir}/mcreate' >>lustre-tests.files +echo '%{_bindir}/munlink' >>lustre-tests.files +echo '%{_bindir}/statx' >>lustre-tests.files +echo '%{_sbindir}/wirecheck' >>lustre-tests.files +echo '%{_sbindir}/wiretest' >>lustre-tests.files +if [ -n "$MPI_BIN" ]; then + echo "$MPI_BIN/*" >>lustre-tests.files +fi +%if %{with lustre_tests_lutf} +echo '%{_libdir}/lustre/tests/lutf/*' >>lustre-tests.files +%endif +%endif + +%if %{with lustre_tests_lutf} +echo '%{_libdir}/lustre/tests/lutf/*' >>lustre-tests.files +%endif + +%files devel -f lustre-devel.files +%defattr(-,root,root) +%{_libdir}/pkgconfig/lustre.pc +%if %{with static} +%{_libdir}/liblustreapi.a +%endif +%if %{with shared} +%{_libdir}/liblustreapi.so +%endif +%{_includedir}/lustre +%if %{with lustre_modules} +%{_includedir}/linux/lnet +%{_includedir}/linux/lustre +%else +%exclude %{_includedir}/linux/lnet +%exclude %{_includedir}/linux/lustre +%endif + +%files -f lustre.files +%defattr(-,root,root) +%{_sbindir}/* +%if %{with lustre_tests} +%exclude %{_sbindir}/wirecheck +%exclude %{_sbindir}/wiretest +%endif +%if %{with zfs} +%exclude %{_sbindir}/zfsobj2fid +%endif +%if %{with lustre_utils} +%if %{with servers} +%{_libexecdir}/lustre/lc_common +%{_libexecdir}/lustre/haconfig +%{_bindir}/lustre_req_history +%{_bindir}/remove_changelog +%{_bindir}/remove_updatelog +%endif + +%{_bindir}/llobdstat +%{_bindir}/lljobstat +%{_bindir}/llstat +%{_bindir}/plot-llstat +%{_datadir}/lustre + +%{_bindir}/lfs +%{_bindir}/lfs_migrate +/sbin/mount.lustre +%if %{with servers} +/sbin/mount.lustre_tgt +%endif +/usr/share/bash-completion/completions +%endif + +%if %{with manpages} +%{_mandir}/man?/* +%endif + +%if %{with shared} +%{_libdir}/liblustreapi.so.* +%endif +%{_sysconfdir}/udev/rules.d/99-lustre.rules +%if %{with servers} +%{_sysconfdir}/udev/rules.d/99-lustre-server.rules +%endif +%if %{with zfs} +%config(noreplace) %{_sysconfdir}/ldev.conf +%endif +%config(noreplace) %{_sysconfdir}/lnet.conf +%config(noreplace) %{_sysconfdir}/modprobe.d/ko2iblnd.conf +%if %{with lustre_utils} +%config(noreplace) %{_sysconfdir}/lnet_routes.conf +%endif +%if %{with lustre_modules} +%if %{with shared} +%if %{with ldiskfs} +%if %{with lustre_utils} +%files osd-ldiskfs-mount +%defattr(-,root,root) +%{_libdir}/lustre/mount_osd_ldiskfs.so +%endif +%endif +%endif + +%if %{with shared} +%if %{with zfs} +%if %{with lustre_utils} +%files osd-zfs-mount +%defattr(-,root,root) +%{_libdir}/lustre/mount_osd_zfs.so +%{_sysconfdir}/zfs/zed.d/* +%endif +%endif +%endif + +# with lustre_modules +%endif + +%if %{with servers} +%files resource-agents +%defattr(0755,root,root) +%{_prefix}/lib/ocf/resource.d/lustre/ +%endif + +%if %{with lustre_tests} +%files tests -f lustre-tests.files +%defattr(-,root,root) +%endif + +%if %{with lustre_iokit} +%files -n lustre-iokit +%defattr(-, root, root) +%{_bindir}/iokit-config +%{_bindir}/iokit-gather-stats + +%{_bindir}/iokit-libecho +%{_bindir}/iokit-lstats +%{_bindir}/iokit-parse-ior +%{_bindir}/iokit-plot-obdfilter +%{_bindir}/iokit-plot-ost +%{_bindir}/iokit-plot-sgpdd +%{_bindir}/ior-survey +%{_bindir}/mds-survey +%{_bindir}/obdfilter-survey +%{_bindir}/ost-survey +%{_bindir}/sgpdd-survey +%doc lustre-iokit/ior-survey/README.ior-survey +%doc lustre-iokit/mds-survey/README.mds-survey +%doc lustre-iokit/obdfilter-survey/README.obdfilter-survey +%doc lustre-iokit/ost-survey/README.ost-survey +%doc lustre-iokit/sgpdd-survey/README.sgpdd-survey +%doc lustre-iokit/stats-collect/README.iokit-lstats +%endif + +%post +%if %{with systemd} +%systemd_post lnet.service +%endif + +%preun +%if %{with systemd} +%systemd_preun lnet.service +%endif + +%postun +%if %{with systemd} +%systemd_postun_with_restart lnet.service +%endif + +%clean +rm -rf $RPM_BUILD_ROOT +rm -rf %{_tmppath}/kmp + +%changelog +* Tue Mar 28 2023 Xinliang Liu - 2.15.54-1 +- Initial RPM release, client support, with kernel 6.1 client patches