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
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
]) # 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 <linux/random.h>
+ ],[
+ 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 <linux/fs.h>
+ ],[
+ 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 <linux/pagemap.h>
+ ],[
+ 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
#
# Lustre linux kernel checks
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
])
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
])
~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;
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
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 = {
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;
}
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;
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)
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);
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
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
}
* \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
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
* \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
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.
#define osd_dquot_transfer(ns, i, a) dquot_transfer((i), (a))
#endif
+#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 */
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
* or filter_fid_18_23), move them back to its proper /O/<seq>/d<x>.
*/
#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;
/* 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;
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;
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;
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;
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)