Whamcloud - gitweb
file lustre_types.h was added on branch b1_4_mountconf on 2006-04-26 18:45:44 +0000
[fs/lustre-release.git] / lustre / obdfilter / filter_lvb.c
index c8a9d9b..ce4d5b3 100644 (file)
@@ -8,20 +8,23 @@
  *   Author: Andreas Dilger <adilger@clusterfs.com>
  *   Author: Phil Schwan <phil@clusterfs.com>
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ *   This file is part of the Lustre file system, http://www.lustre.org
+ *   Lustre is a trademark of Cluster File Systems, Inc.
  *
- *   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.
+ *   You may have signed or agreed to another license before downloading
+ *   this software.  If so, you are bound by the terms and conditions
+ *   of that agreement, and the following does not apply to you.  See the
+ *   LICENSE file included with this distribution for more information.
  *
- *   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.
+ *   If you did not agree to a different license, then this copy of Lustre
+ *   is open source 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.
  *
- *   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.
+ *   In either case, 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
+ *   license text for more details.
  */
 
 #define DEBUG_SUBSYSTEM S_FILTER
 /* Called with res->lr_lvb_sem held */
 static int filter_lvbo_init(struct ldlm_resource *res)
 {
-        int rc = 0;
         struct ost_lvb *lvb = NULL;
         struct obd_device *obd;
         struct dentry *dentry;
+        int rc = 0;
         ENTRY;
 
         LASSERT(res);
@@ -54,11 +57,11 @@ static int filter_lvbo_init(struct ldlm_resource *res)
                 RETURN(0);
 
         if (res->lr_lvb_data)
-                GOTO(out, rc = 0);
+                RETURN(0);
 
         OBD_ALLOC(lvb, sizeof(*lvb));
         if (lvb == NULL)
-                GOTO(out, rc = -ENOMEM);
+                RETURN(-ENOMEM);
 
         res->lr_lvb_data = lvb;
         res->lr_lvb_len = sizeof(*lvb);
@@ -67,8 +70,12 @@ static int filter_lvbo_init(struct ldlm_resource *res)
         LASSERT(obd != NULL);
 
         dentry = filter_fid2dentry(obd, NULL, 0, res->lr_name.name[0]);
-        if (IS_ERR(dentry))
-                GOTO(out, rc = PTR_ERR(dentry));
+        if (IS_ERR(dentry)) {
+                rc = PTR_ERR(dentry);
+                CERROR("%s: bad object "LPU64"/"LPU64": rc %d\n", obd->obd_name,
+                       res->lr_name.name[0], res->lr_name.name[1], rc);
+                RETURN(rc);
+        }
 
         if (dentry->d_inode == NULL)
                 GOTO(out_dentry, rc = -ENOENT);
@@ -82,9 +89,10 @@ static int filter_lvbo_init(struct ldlm_resource *res)
                res->lr_name.name[0], lvb->lvb_size,
                lvb->lvb_mtime, lvb->lvb_blocks);
 
- out_dentry:
+        EXIT;
+out_dentry:
         f_dput(dentry);
- out:
+
         /* Don't free lvb data on lookup error */
         return rc;
 }
@@ -94,13 +102,13 @@ static int filter_lvbo_init(struct ldlm_resource *res)
  *   m != NULL : called by the DLM itself after a glimpse callback
  *   m == NULL : called by the filter after a disk write
  *
- *   If 'increase' is true, don't allow values to move backwards.
+ *   If 'increase_only' is true, don't allow values to move backwards.
  */
 static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
-                              int buf_idx, int increase)
+                              int buf_idx, int increase_only)
 {
         int rc = 0;
-        struct ost_lvb *lvb = res->lr_lvb_data;
+        struct ost_lvb *lvb;
         struct obd_device *obd;
         struct dentry *dentry;
         ENTRY;
@@ -113,6 +121,7 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
                 RETURN(0);
 
         down(&res->lr_lvb_sem);
+        lvb = res->lr_lvb_data;
         if (lvb == NULL) {
                 CERROR("No lvb when running lvbo_update!\n");
                 GOTO(out, rc = 0);
@@ -126,28 +135,27 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
                                       lustre_swab_ost_lvb);
                 if (new == NULL) {
                         CERROR("lustre_swab_buf failed\n");
-                        //GOTO(out, rc = -EPROTO);
-                        GOTO(out, rc = 0);
+                        goto disk_update;
                 }
-                if (new->lvb_size > lvb->lvb_size || !increase) {
+                if (new->lvb_size > lvb->lvb_size || !increase_only) {
                         CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb size: "
                                LPU64" -> "LPU64"\n", res->lr_name.name[0],
                                lvb->lvb_size, new->lvb_size);
                         lvb->lvb_size = new->lvb_size;
                 }
-                if (new->lvb_mtime > lvb->lvb_mtime || !increase) {
+                if (new->lvb_mtime > lvb->lvb_mtime || !increase_only) {
                         CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb mtime: "
                                LPU64" -> "LPU64"\n", res->lr_name.name[0],
                                lvb->lvb_mtime, new->lvb_mtime);
                         lvb->lvb_mtime = new->lvb_mtime;
                 }
-                if (new->lvb_atime > lvb->lvb_atime || !increase) {
+                if (new->lvb_atime > lvb->lvb_atime || !increase_only) {
                         CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb atime: "
                                LPU64" -> "LPU64"\n", res->lr_name.name[0],
                                lvb->lvb_atime, new->lvb_atime);
                         lvb->lvb_atime = new->lvb_atime;
                 }
-                if (new->lvb_ctime > lvb->lvb_ctime || !increase) {
+                if (new->lvb_ctime > lvb->lvb_ctime || !increase_only) {
                         CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb ctime: "
                                LPU64" -> "LPU64"\n", res->lr_name.name[0],
                                lvb->lvb_ctime, new->lvb_ctime);
@@ -155,6 +163,7 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
                 }
         }
 
+ disk_update:
         /* Update the LVB from the disk inode */
         obd = res->lr_namespace->ns_lvbp;
         LASSERT(obd);
@@ -166,26 +175,26 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
         if (dentry->d_inode == NULL)
                 GOTO(out_dentry, rc = -ENOENT);
 
-        if (dentry->d_inode->i_size > lvb->lvb_size || !increase) {
+        if (dentry->d_inode->i_size > lvb->lvb_size || !increase_only) {
                 CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb size from disk: "
                        LPU64" -> %llu\n", res->lr_name.name[0],
                        lvb->lvb_size, dentry->d_inode->i_size);
                 lvb->lvb_size = dentry->d_inode->i_size;
         }
 
-        if (LTIME_S(dentry->d_inode->i_mtime) > lvb->lvb_mtime || !increase) {
+        if (LTIME_S(dentry->d_inode->i_mtime) >lvb->lvb_mtime|| !increase_only){
                 CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb mtime from disk: "
                        LPU64" -> %lu\n", res->lr_name.name[0],
                        lvb->lvb_mtime, LTIME_S(dentry->d_inode->i_mtime));
                 lvb->lvb_mtime = LTIME_S(dentry->d_inode->i_mtime);
         }
-        if (LTIME_S(dentry->d_inode->i_atime) > lvb->lvb_atime || !increase) {
+        if (LTIME_S(dentry->d_inode->i_atime) >lvb->lvb_atime|| !increase_only){
                 CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb atime from disk: "
                        LPU64" -> %lu\n", res->lr_name.name[0],
                        lvb->lvb_atime, LTIME_S(dentry->d_inode->i_atime));
                 lvb->lvb_atime = LTIME_S(dentry->d_inode->i_atime);
         }
-        if (LTIME_S(dentry->d_inode->i_ctime) > lvb->lvb_ctime || !increase) {
+        if (LTIME_S(dentry->d_inode->i_ctime) >lvb->lvb_ctime|| !increase_only){
                 CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb ctime from disk: "
                        LPU64" -> %lu\n", res->lr_name.name[0],
                        lvb->lvb_ctime, LTIME_S(dentry->d_inode->i_ctime));