Whamcloud - gitweb
Commit OST AMD support to HEAD so we can being running with a common code base.
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index 26dec71..906e978 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/lustre_ha.h>
 #include <linux/lustre_dlm.h>
 #include <linux/lprocfs_status.h>
+#include <linux/lustre_snap.h>
 #include "llite_internal.h"
 
 kmem_cache_t *ll_file_data_slab;
@@ -98,17 +99,11 @@ int lustre_init_ea_size(struct ll_sb_info *sbi)
         valsize = sizeof(desc);
         rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc", 
                           &valsize, &desc);
-        if (rc == 0) {
-                obd_init_ea_size(sbi->ll_mdc_exp,
-                                 obd_size_diskmd(sbi->ll_osc_exp, NULL),
-                                 desc.ld_tgt_count*sizeof(struct llog_cookie));
-
-                /* declare ourself as real client. not connection
-                 * from another MDS 
-                 * FIXME: remove fake valsize, mdsize --bzzz */
-                rc = obd_set_info(sbi->ll_mdc_exp, strlen("client"),
-                                  "client", valsize, &desc);
-        }
+        if (rc)
+                RETURN(rc);
+        obd_init_ea_size(sbi->ll_mdc_exp, obd_size_diskmd(sbi->ll_osc_exp, NULL),
+                         desc.ld_tgt_count*sizeof(struct llog_cookie));
+
         RETURN(rc);
 }
 
@@ -139,7 +134,7 @@ int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
                         CERROR("could not register mount in /proc/lustre");
         }
 
-        err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid);
+        err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0);
         if (err == -EBUSY) {
                 CERROR("An MDS (mdc %s) is performing recovery, of which this"
                        " client is not a part.  Please wait for recovery to "
@@ -172,7 +167,7 @@ int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
                 GOTO(out_mdc, err);
         }
 
-        err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid);
+        err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0);
         if (err == -EBUSY) {
                 CERROR("An OST (osc %s) is performing recovery, of which this"
                        " client is not a part.  Please wait for recovery to "
@@ -241,6 +236,12 @@ int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
 #endif
 
         sb->s_root = d_alloc_root(root);
+
+#ifdef S_PDIROPS
+        CWARN("Enabling PDIROPS\n");
+        sb->s_flags |= S_PDIROPS;
+#endif
+
         RETURN(err);
 
 out_root:
@@ -324,7 +325,8 @@ int ll_set_opt(const char *opt, char *data, int fl)
                 RETURN(fl);
 }
 
-void ll_options(char *options, char **ost, char **mdc, int *flags)
+void ll_options(char *options, char **ost, char **mdc, int *flags, 
+                char **clone_opts)
 {
         char *this_char;
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
@@ -349,12 +351,16 @@ void ll_options(char *options, char **ost, char **mdc, int *flags)
                         continue;
                 if (!*mdc && (*mdc = ll_read_opt("mdc", this_char)))
                         continue;
+                if (!*clone_opts && (*clone_opts = ll_read_opt("clone", 
+                                                                this_char))) 
+                        continue; 
                 if (!(*flags & LL_SBI_NOLCK) &&
                     ((*flags) = (*flags) |
                                 ll_set_opt("nolock", this_char,
                                            LL_SBI_NOLCK)))
                         continue;
         }
+        
         EXIT;
 }
 
@@ -365,6 +371,7 @@ void ll_lli_init(struct ll_inode_info *lli)
         lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
         spin_lock_init(&lli->lli_lock);
         INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
+        lli->lli_inode_magic = LLI_INODE_MAGIC;
 }
 
 int ll_fill_super(struct super_block *sb, void *data, int silent)
@@ -372,6 +379,7 @@ int ll_fill_super(struct super_block *sb, void *data, int silent)
         struct ll_sb_info *sbi;
         char *osc = NULL;
         char *mdc = NULL;
+        char *clone_opts = NULL;
         int err;
         ENTRY;
 
@@ -382,7 +390,7 @@ int ll_fill_super(struct super_block *sb, void *data, int silent)
                 RETURN(-ENOMEM);
 
         sbi->ll_flags |= LL_SBI_READAHEAD;
-        ll_options(data, &osc, &mdc, &sbi->ll_flags);
+        ll_options(data, &osc, &mdc, &sbi->ll_flags, &clone_opts);
 
         if (!osc) {
                 CERROR("no osc\n");
@@ -403,6 +411,8 @@ out:
                 OBD_FREE(mdc, strlen(mdc) + 1);
         if (osc)
                 OBD_FREE(osc, strlen(osc) + 1);
+        if (clone_opts)
+                OBD_FREE(clone_opts, strlen(clone_opts) + 1);
 
         RETURN(err);
 } /* ll_read_super */
@@ -490,7 +500,7 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
         if (err)
                 GOTO(out_cleanup, err);
 
-        err = obd_connect(&mdc_conn, obd, &mdc_uuid);
+        err = obd_connect(&mdc_conn, obd, &mdc_uuid, 0);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
                 GOTO(out_cleanup, err);
@@ -624,7 +634,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
 
         if (err)
                 GOTO(out_free, err);
-
+        
 out_dev:
         if (mdc)
                 OBD_FREE(mdc, strlen(mdc) + 1);
@@ -705,7 +715,6 @@ void lustre_put_super(struct super_block *sb)
         obd = NULL;
 
         lustre_common_put_super(sb);
-
         if (sbi->ll_lmd != NULL) {
                 char * cln_prof;
                 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
@@ -814,23 +823,29 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean)
 
 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
 {
-        struct inode *inode;
+        struct inode *inode = NULL;
         l_lock(&lock->l_resource->lr_namespace->ns_lock);
-        if (lock->l_ast_data)
-                inode = igrab(lock->l_ast_data);
-        else
-                inode = NULL;
+        if (lock->l_ast_data) {
+                struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
+                if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
+                        inode = igrab(lock->l_ast_data);
+                } else {
+                        CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
+                               lock->l_ast_data, lli->lli_inode_magic);
+                }
+        }
         l_unlock(&lock->l_resource->lr_namespace->ns_lock);
         return inode;
 }
 
 int null_if_equal(struct ldlm_lock *lock, void *data)
 {
-        if (data == lock->l_ast_data)
+        if (data == lock->l_ast_data) {
                 lock->l_ast_data = NULL;
 
-        if (lock->l_req_mode != lock->l_granted_mode)
-                return LDLM_ITER_STOP;
+                if (lock->l_req_mode != lock->l_granted_mode)
+                        LDLM_ERROR(lock,"clearing inode with ungranted lock\n");
+        }
 
         return LDLM_ITER_CONTINUE;
 }
@@ -845,6 +860,7 @@ void ll_clear_inode(struct inode *inode)
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
                inode->i_generation, inode);
 
+        lli->lli_inode_magic = LLI_INODE_DEAD;
         ll_inode2fid(&fid, inode);
         clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
         md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
@@ -1136,14 +1152,6 @@ int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
         return 0;
 }
 
-void dump_lsm(int level, struct lov_stripe_md *lsm)
-{
-        CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
-               "stripe_size %u, stripe_count %u\n",
-               lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
-               lsm->lsm_stripe_size, lsm->lsm_stripe_count);
-}
-
 void ll_update_inode(struct inode *inode, struct lustre_md *md)
 {
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -1334,6 +1342,25 @@ void ll_read_inode2(struct inode *inode, void *opaque)
         }
 }
 
+void ll_delete_inode(struct inode *inode)
+{
+        int rc;
+        struct ll_fid fid;
+        struct ll_sb_info *sbi = ll_i2sbi(inode);
+        ENTRY;
+        
+        ll_inode2fid(&fid, inode);
+
+        rc = md_delete_object(sbi->ll_mdc_exp, &fid);
+        if (rc) {
+                CERROR("md_delete_object() failed, error %d.\n",
+                       rc);
+        }
+
+        clear_inode(inode);
+        EXIT;
+}
+
 int ll_iocontrol(struct inode *inode, struct file *file,
                  unsigned int cmd, unsigned long arg)
 {