Whamcloud - gitweb
smash the HEAD with the contents of b_cmd. HEAD_PRE_CMD_SMASH and
[fs/lustre-release.git] / lustre / smfs / symlink.c
index 42b6ab6..e1ca762 100644 (file)
@@ -1,86 +1,74 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
+/*
+ *  smfs/symlink.c
  *
- *  Copyright (C) 2004 Cluster File Systems, Inc.
- *
- *   This file is part of Lustre, http://www.lustre.org.
- *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
- *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
-
-#define DEBUG_SUBSYSTEM S_SM
+#define DEBUG_SUBSYSTEM S_SNAP
 
 #include <linux/kmod.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/obd_class.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
-#include <linux/lustre_smfs.h>
 
-#include "smfs_internal.h"
+#include "smfs_internal.h" 
 
-static int smfs_readlink(struct dentry *dentry, char *buffer, int buflen)
+static int smfs_readlink(struct dentry * dentry, char * buffer, int buflen)
 {
-        struct inode *cache_inode = I2CI(dentry->d_inode);
-        struct dentry *cache_dentry;
-        int rc = 0;
-        ENTRY;
-
-        if (!cache_inode)
-                RETURN(-ENOENT);
+       struct inode *cache_inode = I2CI(dentry->d_inode);
+       struct inode *cache_dir = NULL;
+       struct dentry *cache_dentry;
+       struct dentry parent;
+       int    rc = 0;
 
-        cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
-        if (!cache_dentry)
-                GOTO(exit, rc = -ENOMEM);
-        if (cache_inode->i_op && cache_inode->i_op->readlink)
-                rc = cache_inode->i_op->readlink(cache_dentry, buffer, buflen);
-        GOTO(exit, rc);
-exit:
-        post_smfs_dentry(cache_dentry);
-        return rc;
+       if (!cache_inode)
+               RETURN(-ENOENT);
+       if (dentry->d_parent && dentry->d_parent->d_inode){
+               cache_dir = I2CI(dentry->d_parent->d_inode);
+               prepare_parent_dentry(&parent, cache_dir);
+       }       
+       cache_dentry = d_alloc(&parent, &dentry->d_name);
+       d_add(cache_dentry, cache_inode);
+       igrab(cache_inode);
+               
+       if (cache_inode->i_op && cache_inode->i_op->readlink)   
+               rc = cache_inode->i_op->readlink(cache_dentry, buffer, buflen);
+       
+       d_unalloc(cache_dentry);
+       return rc;
 }
 
 static int smfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-        struct inode *cache_inode = I2CI(dentry->d_inode);
-        struct dentry *cache_dentry;
-        int rc = 0;
-        ENTRY;
+       struct inode *cache_inode = I2CI(dentry->d_inode);
+       struct inode *cache_dir = NULL;
+       struct dentry *cache_dentry;
+       struct dentry parent;
+       int rc = 0;
+       if (!cache_inode)
+               RETURN(-ENOENT);
 
-        if (!cache_inode)
-                RETURN(-ENOENT);
+       if (dentry->d_parent && dentry->d_parent->d_inode){
+               cache_dir = I2CI(dentry->d_parent->d_inode);
+               prepare_parent_dentry(&parent, cache_dir);
+       }       
 
-        cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
-        if (!cache_dentry)
-                GOTO(exit, rc = -ENOMEM);
+       cache_dentry = d_alloc(&parent, &dentry->d_name);
 
-        if (cache_inode->i_op && cache_inode->i_op->follow_link)
-                rc = cache_inode->i_op->follow_link(cache_dentry, nd);
-exit:
-        post_smfs_dentry(cache_dentry);
-        return rc;
+       d_add(cache_dentry, cache_inode);
+       igrab(cache_inode);
+       
+       if (cache_inode->i_op && cache_inode->i_op->follow_link)        
+               rc = cache_inode->i_op->follow_link(cache_dentry, nd);
+       
+       d_unalloc(cache_dentry);
+       return rc;
 }
-
 struct inode_operations smfs_sym_iops = {
-        readlink:        smfs_readlink,
-        follow_link:        smfs_follow_link,
-        setxattr:       smfs_setxattr,          /* BKL held */
+       readlink:       smfs_readlink,
+       follow_link:    smfs_follow_link,
+       setxattr:       smfs_setxattr,          /* BKL held */
         getxattr:       smfs_getxattr,          /* BKL held */
         listxattr:      smfs_listxattr,         /* BKL held */
         removexattr:    smfs_removexattr,       /* BKL held */