Whamcloud - gitweb
b=19047
[fs/lustre-release.git] / lustre / llite / llite_close.c
index 326adf4..14c76a0 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.
+ *
+ * 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.
  *
- *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
+ * 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).
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * 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 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.
+ * 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.
+ *
+ * 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 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.
+ * lustre/llite/llite_close.c
  *
- *   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.
+ * Lustre Lite routines to issue a secondary close after writeback
  */
 
 #include <linux/module.h>
 #include <lustre_lite.h>
 #include "llite_internal.h"
 
-/* record that a write is in flight */
-void llap_write_pending(struct inode *inode, struct ll_async_page *llap)
+/** records that a write is in flight */
+void vvp_write_pending(struct ccc_object *club, struct ccc_page *page)
 {
-        struct ll_inode_info *lli = ll_i2info(inode);
+        struct ll_inode_info *lli = ll_i2info(club->cob_inode);
 
         ENTRY;
         spin_lock(&lli->lli_lock);
         lli->lli_flags |= LLIF_SOM_DIRTY;
-        if (llap && list_empty(&llap->llap_pending_write))
-                list_add(&llap->llap_pending_write, 
-                         &lli->lli_pending_write_llaps);
+        if (page != NULL && list_empty(&page->cpg_pending_linkage))
+                list_add(&page->cpg_pending_linkage, &club->cob_pending_list);
         spin_unlock(&lli->lli_lock);
         EXIT;
 }
 
-/* record that a write has completed */
-int llap_write_complete(struct inode *inode, struct ll_async_page *llap)
+/** records that a write has completed */
+void vvp_write_complete(struct ccc_object *club, struct ccc_page *page)
 {
-        struct ll_inode_info *lli = ll_i2info(inode);
+        struct ll_inode_info *lli = ll_i2info(club->cob_inode);
         int rc = 0;
-        
+
         ENTRY;
         spin_lock(&lli->lli_lock);
-        if (llap && !list_empty(&llap->llap_pending_write)) {
-                list_del_init(&llap->llap_pending_write);
+        if (page != NULL && !list_empty(&page->cpg_pending_linkage)) {
+                list_del_init(&page->cpg_pending_linkage);
                 rc = 1;
         }
         spin_unlock(&lli->lli_lock);
-        RETURN(rc);
+        if (rc)
+                ll_queue_done_writing(club->cob_inode, 0);
+        EXIT;
 }
 
-/* Queue DONE_WRITING if 
+/** Queues DONE_WRITING if
  * - done writing is allowed;
  * - inode has no no dirty pages; */
 void ll_queue_done_writing(struct inode *inode, unsigned long flags)
@@ -77,7 +95,7 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags)
                 if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
                          CWARN("ino %lu/%u(flags %lu) som valid it just after "
                                "recovery\n",
-                               inode->i_ino, inode->i_generation, 
+                               inode->i_ino, inode->i_generation,
                                lli->lli_flags);
                 /* DONE_WRITING is allowed and inode has no dirty page. */
                 spin_lock(&lcq->lcq_lock);
@@ -101,8 +119,8 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags)
         spin_unlock(&lli->lli_lock);
 }
 
-/* Close epoch and send Size-on-MDS attribute update if possible. 
- * Call this under @lli->lli_lock spinlock. */
+/** Closes epoch and sends Size-on-MDS attribute update if possible.  Call
+ * this under ll_inode_info::lli_lock spinlock. */
 void ll_epoch_close(struct inode *inode, struct md_op_data *op_data,
                     struct obd_client_handle **och, unsigned long flags)
 {
@@ -123,7 +141,7 @@ void ll_epoch_close(struct inode *inode, struct md_op_data *op_data,
                         inode = igrab(inode);
                         LASSERT(inode);
                         GOTO(out, 0);
-                } 
+                }
                 if (flags & LLIF_DONE_WRITING) {
                         /* Some pages are still dirty, it is early to send
                          * DONE_WRITE. Wait untill all pages will be flushed
@@ -173,7 +191,7 @@ void ll_epoch_close(struct inode *inode, struct md_op_data *op_data,
                       "recovery\n",
                       inode->i_ino, inode->i_generation, lli->lli_flags);
 
-        if (!ll_local_size(inode)) {
+        if (!cl_local_size(inode)) {
                 /* Send Size-on-MDS Attributes if valid. Atime is sent along
                  * with all the attributes. */
                 op_data->op_attr.ia_valid |= ATTR_MTIME_SET | ATTR_CTIME_SET |
@@ -192,7 +210,7 @@ int ll_sizeonmds_update(struct inode *inode, struct lustre_handle *fh,
         struct obdo *oa;
         int rc;
         ENTRY;
-        
+
         /* LASSERT(!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)); */
         /* After recovery that can be valid. */
         if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
@@ -207,7 +225,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 +243,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, NULL);
         EXIT;
 out:
         if (oa)
@@ -231,7 +253,8 @@ out:
         return rc;
 }
 
-/* Send a DONE_WRITING rpc, pack Size-on-MDS attributes into it, if possible */
+/** Sends a DONE_WRITING rpc, packs Size-on-MDS attributes into it, if
+ * possible */
 static void ll_done_writing(struct inode *inode)
 {
         struct obd_client_handle *och = NULL;
@@ -240,7 +263,7 @@ static void ll_done_writing(struct inode *inode)
         ENTRY;
 
         LASSERT(ll_i2mdexp(inode)->exp_connect_flags & OBD_CONNECT_SOM);
-        
+
         OBD_ALLOC_PTR(op_data);
         if (op_data == NULL) {
                 CERROR("can't allocate op_data\n");
@@ -252,12 +275,12 @@ static void ll_done_writing(struct inode *inode)
         /* If there is no @och, we do not do D_W yet. */
         if (och == NULL)
                 GOTO(out, 0);
-        
+
         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, NULL);
         if (rc == -EAGAIN) {
-                /* MDS has instructed us to obtain Size-on-MDS attribute from 
+                /* 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);
@@ -301,7 +324,7 @@ static int ll_close_thread(void *arg)
                 snprintf(name, sizeof(name) - 1, "ll_close");
                 cfs_daemonize(name);
         }
-        
+
         complete(&lcq->lcq_comp);
 
         while (1) {
@@ -332,6 +355,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 +386,3 @@ void ll_close_thread_shutdown(struct ll_close_queue *lcq)
         wait_for_completion(&lcq->lcq_comp);
         OBD_FREE(lcq, sizeof(*lcq));
 }
-
-