Whamcloud - gitweb
land 0.5.20.3 b_devel onto HEAD (b_devel will remain)
[fs/lustre-release.git] / lustre / mds / mds_fs.c
index 3f6c420..39e8592 100644 (file)
@@ -1,17 +1,26 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  linux/mds/mds_fs.c
- *
+ *  mds/mds_fs.c
  *  Lustre Metadata Server (MDS) filesystem interface code
  *
- *  Copyright (C) 2002 Cluster File Systems, Inc.
+ *  Copyright (C) 2002, 2003 Cluster File Systems, Inc.
+ *   Author: Andreas Dilger <adilger@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
  *
- *  This code is issued under the GNU General Public License.
- *  See the file COPYING in this distribution
+ *   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.
  *
- *  by Andreas Dilger <adilger@clusterfs.com>
+ *   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 EXPORT_SYMTAB
 
 #include <linux/module.h>
 #include <linux/kmod.h>
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+#include <linux/mount.h>
+#endif
 #include <linux/lustre_mds.h>
 #include <linux/obd_class.h>
 #include <linux/obd_support.h>
@@ -79,8 +92,8 @@ int mds_client_add(struct mds_obd *mds, struct mds_export_data *med, int cl_off)
 
                 push_ctxt(&saved, &mds->mds_ctxt, NULL);
                 written = lustre_fwrite(mds->mds_rcvd_filp,
-                                                (char *)med->med_mcd,
-                                                sizeof(*med->med_mcd), &off);
+                                        (char *)med->med_mcd,
+                                        sizeof(*med->med_mcd), &off);
                 pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
                 if (written != sizeof(*med->med_mcd)) {
@@ -154,7 +167,7 @@ static int mds_read_last_rcvd(struct obd_device *obddev, struct file *f)
         loff_t off = 0;
         int cl_off;
         unsigned long last_rcvd_size = f->f_dentry->d_inode->i_size;
-        __u64 last_rcvd = 0;
+        __u64 last_transno = 0;
         __u64 last_mount;
         int rc = 0;
 
@@ -177,16 +190,16 @@ static int mds_read_last_rcvd(struct obd_device *obddev, struct file *f)
         }
 
         CDEBUG(D_INODE, "last_rcvd has size %lu (msd + %lu clients)\n",
-               last_rcvd_size, (last_rcvd_size - sizeof *msd) / sizeof *mcd);
+               last_rcvd_size, (last_rcvd_size - MDS_LR_CLIENT)/MDS_LR_SIZE);
 
         /*
-         * When we do a clean MDS shutdown, we save the last_rcvd into
-         * the header.  If we find clients with higher last_rcvd values
-         * then those clients may need recovery done.
+         * When we do a clean MDS shutdown, we save the last_transno into
+         * the header.
          */
-        last_rcvd = le64_to_cpu(msd->msd_last_rcvd);
-        mds->mds_last_rcvd = last_rcvd;
-        CDEBUG(D_INODE, "got "LPU64" for server last_rcvd value\n", last_rcvd);
+        last_transno = le64_to_cpu(msd->msd_last_transno);
+        mds->mds_last_transno = last_transno;
+        CDEBUG(D_INODE, "got "LPU64" for server last_rcvd value\n",
+               last_transno);
 
         last_mount = le64_to_cpu(msd->msd_mount_count);
         mds->mds_mount_count = last_mount;
@@ -217,7 +230,7 @@ static int mds_read_last_rcvd(struct obd_device *obddev, struct file *f)
                         continue;
                 }
 
-                last_rcvd = le64_to_cpu(mcd->mcd_last_rcvd);
+                last_transno = le64_to_cpu(mcd->mcd_last_transno);
 
                 /* These exports are cleaned up by mds_disconnect(), so they
                  * need to be set up like real exports as mds_connect() does.
@@ -232,6 +245,8 @@ static int mds_read_last_rcvd(struct obd_device *obddev, struct file *f)
                                 break;
                         }
 
+                        memcpy(&exp->exp_client_uuid.uuid, mcd->mcd_uuid,
+                               sizeof exp->exp_client_uuid.uuid);
                         med = &exp->exp_mds_data;
                         med->med_mcd = mcd;
                         mds_client_add(mds, med, cl_off);
@@ -240,7 +255,7 @@ static int mds_read_last_rcvd(struct obd_device *obddev, struct file *f)
                         spin_lock_init(&med->med_open_lock);
 
                         mcd = NULL;
-                        mds->mds_recoverable_clients++;
+                        obddev->obd_recoverable_clients++;
                 } else {
                         CDEBUG(D_INFO,
                                "discarded client %d, UUID '%s', count %Ld\n",
@@ -249,17 +264,20 @@ static int mds_read_last_rcvd(struct obd_device *obddev, struct file *f)
                 }
 
                 CDEBUG(D_OTHER, "client at offset %d has last_rcvd = %Lu\n",
-                       cl_off, (unsigned long long)last_rcvd);
+                       cl_off, (unsigned long long)last_transno);
 
-                if (last_rcvd > mds->mds_last_rcvd)
-                        mds->mds_last_rcvd = last_rcvd;
+                if (last_transno > mds->mds_last_transno)
+                        mds->mds_last_transno = last_transno;
         }
 
-        mds->mds_last_committed = mds->mds_last_rcvd;
-        if (mds->mds_recoverable_clients) {
-                CERROR("RECOVERY: %d recoverable clients, last_rcvd "LPU64"\n",
-                       mds->mds_recoverable_clients, mds->mds_last_rcvd);
-                mds->mds_next_recovery_transno = mds->mds_last_committed + 1;
+        obddev->obd_last_committed = mds->mds_last_transno;
+        if (obddev->obd_recoverable_clients) {
+                CERROR("RECOVERY: %d recoverable clients, last_transno "
+                       LPU64"\n",
+                       obddev->obd_recoverable_clients, mds->mds_last_transno);
+                obddev->obd_next_recovery_transno = obddev->obd_last_committed
+                        + 1;
+                obddev->obd_flags |= OBD_RECOVERING;
         }
 
         if (mcd)