From bcde98b42d312985684a05b6943d5b3a3ef94a4b Mon Sep 17 00:00:00 2001
From: alex <alex>
Date: Tue, 29 Jun 2004 16:55:53 +0000
Subject: [PATCH] - support for raw lookup in mds_getattr_name() - configure
 script sets HAVE_LOOKUP_RAW if kernel has the feature

---
 lnet/archdep.m4           | 11 +++++++++++
 lustre/mds/handler.c      | 17 ++++++++++++++---
 lustre/portals/archdep.m4 | 11 +++++++++++
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/lnet/archdep.m4 b/lnet/archdep.m4
index cb6e0a22f6..95f5ebe821 100644
--- a/lnet/archdep.m4
+++ b/lnet/archdep.m4
@@ -545,6 +545,17 @@ if test x$enable_modules != xno ; then
 	fi # BACKINGFS = ext3
 fi
 
+# ---------- check ->lookup_raw() support --------
+
+AC_MSG_CHECKING([if kernel supports ->lookup_raw()])
+HAVE_LOOKUP_RAW="`grep -c 'lookup_raw.*struct inode' $LINUX/include/linux/proc_fs.h`"
+if test "$HAVE_LOOKUP_RAW" != 0 ; then
+	AC_DEFINE(HAVE_LOOKUP_RAW, 1, [the kernel supports ->lookup_raw()])
+	AC_MSG_RESULT([yes])
+else
+	AC_MSG_RESULT([no])
+fi
+
 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index c1ba5f1c0d..345786336d 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -913,21 +913,32 @@ static int mds_getattr_name(int offset, struct ptlrpc_request *req,
                 goto fill_inode;
         }
         
+#if HAVE_LOOKUP_RAW
         /* FIXME: handle raw lookup */
-#if 0
         if (body->valid == OBD_MD_FLID) {
+                struct mds_obd *mds = &obd->u.mds;
                 struct mds_body *mds_reply;
                 int size = sizeof(*mds_reply);
+                struct inode *dir;
                 ino_t inum;
+                dparent = mds_fid2dentry(mds, &body->fid1, NULL);
+                if (IS_ERR(dparent)) {
+                        rc = PTR_ERR(dparent);
+                        GOTO(cleanup, rc);
+                }
+                LASSERT(dparent != NULL);
+                LASSERT(dparent->d_inode != NULL);
                 // The user requested ONLY the inode number, so do a raw lookup
                 rc = lustre_pack_reply(req, 1, &size, NULL);
                 if (rc) {
                         CERROR("out of memory\n");
+                        l_dput(dparent);
                         GOTO(cleanup, rc);
                 }
-
+                dir  = dparent->d_inode;
+                LASSERT(dir->i_op->lookup_raw != NULL);
                 rc = dir->i_op->lookup_raw(dir, name, namesize - 1, &inum);
-
+                l_dput(dparent);
                 mds_reply = lustre_msg_buf(req->rq_repmsg, offset,
                                            sizeof(*mds_reply));
                 mds_reply->fid1.id = inum;
diff --git a/lustre/portals/archdep.m4 b/lustre/portals/archdep.m4
index cb6e0a22f6..95f5ebe821 100644
--- a/lustre/portals/archdep.m4
+++ b/lustre/portals/archdep.m4
@@ -545,6 +545,17 @@ if test x$enable_modules != xno ; then
 	fi # BACKINGFS = ext3
 fi
 
+# ---------- check ->lookup_raw() support --------
+
+AC_MSG_CHECKING([if kernel supports ->lookup_raw()])
+HAVE_LOOKUP_RAW="`grep -c 'lookup_raw.*struct inode' $LINUX/include/linux/proc_fs.h`"
+if test "$HAVE_LOOKUP_RAW" != 0 ; then
+	AC_DEFINE(HAVE_LOOKUP_RAW, 1, [the kernel supports ->lookup_raw()])
+	AC_MSG_RESULT([yes])
+else
+	AC_MSG_RESULT([no])
+fi
+
 CPPFLAGS="-include \$(top_builddir)/include/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/include/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
-- 
GitLab