Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / llite / llite_close.c
index 326adf4..1c973b6 100644 (file)
@@ -1,24 +1,41 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Lustre Lite routines to issue a secondary close after writeback
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * This program 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   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 should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   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.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
  *
- *   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.
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/llite/llite_close.c
+ *
+ * Lustre Lite routines to issue a secondary close after writeback
  */
 
 #include <linux/module.h>
@@ -184,8 +201,8 @@ out:
         return;
 }
 
-int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh,
-                        __u64 ioepoch)
+int ll_sizeonmds_update(struct inode *inode, struct md_open_data *mod,
+                        struct lustre_handle *fh, __u64 ioepoch)
 {
         struct ll_inode_info *lli = ll_i2info(inode);
         struct md_op_data *op_data;
@@ -207,7 +224,11 @@ int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh,
                 RETURN(-ENOMEM);
         }
         rc = ll_inode_getattr(inode, oa);
-        if (rc) {
+        if (rc == -ENOENT) {
+                oa->o_valid = 0;
+                CDEBUG(D_INODE, "objid "LPX64" is already destroyed\n",
+                       lli->lli_smd->lsm_object_id);
+        } else if (rc) {
                 CERROR("inode_getattr failed (%d): unable to send a "
                        "Size-on-MDS attribute update for inode %lu/%u\n",
                        rc, inode->i_ino, inode->i_generation);
@@ -221,7 +242,7 @@ int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh,
         op_data->op_ioepoch = ioepoch;
         op_data->op_flags |= MF_SOM_CHANGE;
 
-        rc = ll_md_setattr(inode, op_data);
+        rc = ll_md_setattr(inode, op_data, &mod);
         EXIT;
 out:
         if (oa)
@@ -255,12 +276,12 @@ static void ll_done_writing(struct inode *inode)
         
         ll_pack_inode2opdata(inode, op_data, &och->och_fh);
 
-        rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, och);
+        rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, och->och_mod);
         if (rc == -EAGAIN) {
                 /* MDS has instructed us to obtain Size-on-MDS attribute from 
                  * OSTs and send setattr to back to MDS. */
-                rc = ll_sizeonmds_update(inode, &och->och_fh,
-                                         op_data->op_ioepoch);
+                rc = ll_sizeonmds_update(inode, och->och_mod,
+                                         &och->och_fh, op_data->op_ioepoch);
         } else if (rc) {
                 CERROR("inode %lu mdc done_writing failed: rc = %d\n",
                        inode->i_ino, rc);
@@ -332,6 +353,9 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
         struct ll_close_queue *lcq;
         pid_t pid;
 
+        if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD))
+                return -EINTR;
+
         OBD_ALLOC(lcq, sizeof(*lcq));
         if (lcq == NULL)
                 return -ENOMEM;
@@ -360,5 +384,3 @@ void ll_close_thread_shutdown(struct ll_close_queue *lcq)
         wait_for_completion(&lcq->lcq_comp);
         OBD_FREE(lcq, sizeof(*lcq));
 }
-
-