Whamcloud - gitweb
LU-16302 llite: Use alloc_inode_sb() to allocate inodes
authorShaun Tancheff <shaun.tancheff@hpe.com>
Tue, 31 Jan 2023 20:05:06 +0000 (12:05 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 16 Feb 2023 21:17:51 +0000 (21:17 +0000)
linux-commit: v5.17-49-g8b9f3ac5b01d
  fs: introduce alloc_inode_sb() to allocate filesystems specific
      inode

Filesystems are expected to use alloc_inode_sb to allocate inodes
for proper lru handling.

Lustre-change: https://review.whamcloud.com/49070
Lustre-commit: a883fec55694491a26b664c2cff7fb904f72b7af

Test-Parameters: trivial
HPE-bug-id: LUS-11332
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: Ie6f091a01df33738ed2ef6f7fef9c1f9c1a51e03
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49852
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/llite/super25.c

index 142c7a1..0701f21 100644 (file)
@@ -2690,9 +2690,6 @@ kiocb_ki_complete_2args, [
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_HAVE_KIOCB_COMPLETE_2ARGS
 
-AC_DEFUN([LC_PROG_LINUX_SRC], [])
-AC_DEFUN([LC_PROG_LINUX_RESULTS], [])
-
 #
 # LC_HAVE_INVALIDATE_FOLIO
 #
@@ -2743,6 +2740,33 @@ EXTRA_KCFLAGS="$tmp_flags"
 ]) # LC_HAVE_DIRTY_FOLIO
 
 #
+# LC_HAVE_ALLOC_INODE_SB
+#
+# 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, [
+               #include <linux/fs.h>
+       ],[
+               struct super_block *sb = NULL;
+               struct kmem_cache *cache = NULL;
+
+               (void)alloc_inode_sb(sb, cache, GFP_NOFS);
+       ],[
+               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_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2944,10 +2968,13 @@ AC_DEFUN([LC_PROG_LINUX], [
        # 5.16
        LC_HAVE_KIOCB_COMPLETE_2ARGS
 
-       # 5.18
+       # 5.17
        LC_HAVE_INVALIDATE_FOLIO
        LC_HAVE_DIRTY_FOLIO
 
+       # 5.18
+       LC_HAVE_ALLOC_INODE_SB
+
        # kernel patch to extend integrity interface
        LC_BIO_INTEGRITY_PREP_FN
 
index 2c0bb31..a9e8825 100644 (file)
@@ -49,10 +49,17 @@ static struct kmem_cache *ll_inode_cachep;
 static struct inode *ll_alloc_inode(struct super_block *sb)
 {
        struct ll_inode_info *lli;
+#ifdef HAVE_ALLOC_INODE_SB
+       lli = alloc_inode_sb(sb, ll_inode_cachep, GFP_NOFS);
+       if (!lli)
+               return NULL;
+       OBD_ALLOC_POST(lli, sizeof(*lli), "slab-alloced");
+       memset(lli, 0, sizeof(*lli));
+#else
        OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, GFP_NOFS);
-       if (lli == NULL)
+       if (!lli)
                return NULL;
-
+#endif
        inode_init_once(&lli->lli_vfs_inode);
        return &lli->lli_vfs_inode;
 }