Whamcloud - gitweb
Land b1_8_gate onto b1_8 (20081218_1708)
[fs/lustre-release.git] / lustre / llite / llite_close.c
index 6158713..ff3bd0e 100644 (file)
@@ -1,34 +1,51 @@
 /* -*- 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.
+ *
+ * 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).
  *
- *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
+ * 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
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * 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.
  *
- *   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.
+ * 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>
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <lustre_lite.h>
 #include "llite_internal.h"
 
+#ifdef HAVE_CLOSE_THREAD
 /* record that a write is in flight */
 void llap_write_pending(struct inode *inode, struct ll_async_page *llap)
 {
@@ -43,8 +60,7 @@ void llap_write_complete(struct inode *inode, struct ll_async_page *llap)
 {
         struct ll_inode_info *lli = ll_i2info(inode);
         spin_lock(&lli->lli_lock);
-        if (!list_empty(&llap->llap_pending_write))
-                list_del_init(&llap->llap_pending_write);
+        list_del_init(&llap->llap_pending_write);
         spin_unlock(&lli->lli_lock);
 }
 
@@ -85,7 +101,7 @@ void ll_try_done_writing(struct inode *inode)
                 if (list_empty(&lli->lli_close_item)) {
                         CDEBUG(D_INODE, "adding inode %lu/%u to close list\n",
                                inode->i_ino, inode->i_generation);
-                        LASSERT(igrab(inode) == inode);
+                        igrab(inode);
                         list_add_tail(&lli->lli_close_item, &lcq->lcq_list);
                         wake_up(&lcq->lcq_waitq);
                 }
@@ -109,7 +125,6 @@ void ll_queue_done_writing(struct inode *inode)
         EXIT;
 }
 
-#if 0
 /* If we know the file size and have the cookies:
  *  - send a DONE_WRITING rpc
  *
@@ -124,6 +139,7 @@ static void ll_close_done_writing(struct inode *inode)
         ldlm_policy_data_t policy = { .l_extent = {0, OBD_OBJECT_EOF } };
         struct lustre_handle lockh = { 0 };
         struct obdo obdo;
+        struct mdc_op_data data = { { 0 } };
         obd_flag valid;
         int rc, ast_flags = 0;
         ENTRY;
@@ -153,8 +169,8 @@ static void ll_close_done_writing(struct inode *inode)
         obdo_refresh_inode(inode, &obdo, valid);
 
         CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %lu, blksize %lu\n",
-               lli->lli_smd->lsm_object_id, inode->i_size, inode->i_blocks,
-               inode->i_blksize);
+               lli->lli_smd->lsm_object_id, i_size_read(inode), inode->i_blocks,
+               1<<inode->i_blkbits);
 
         set_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags);
 
@@ -164,14 +180,15 @@ static void ll_close_done_writing(struct inode *inode)
 
  rpc:
         obdo.o_id = inode->i_ino;
-        obdo.o_size = inode->i_size;
+        obdo.o_size = i_size_read(inode);
         obdo.o_blocks = inode->i_blocks;
         obdo.o_valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
 
-        rc = md_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &obdo);
+        ll_inode2fid(&data.fid1, inode);
+        rc = mdc_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &data, &obdo);
  out:
 }
-#endif
+
 
 static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq)
 {
@@ -190,24 +207,27 @@ static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq)
         spin_unlock(&lcq->lcq_lock);
         return lli;
 }
+#else
+static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq)
+{
+        if (lcq->lcq_list.next == NULL)
+                return ERR_PTR(-1);
+
+       return NULL;
+}
+#endif
 
 static int ll_close_thread(void *arg)
 {
         struct ll_close_queue *lcq = arg;
         ENTRY;
 
-        /* XXX boiler-plate */
         {
-                char name[sizeof(current->comm)];
-                unsigned long flags;
+                char name[CFS_CURPROC_COMM_MAX];
                 snprintf(name, sizeof(name) - 1, "ll_close");
-                kportal_daemonize(name);
-                SIGNAL_MASK_LOCK(current, flags);
-                sigfillset(&current->blocked);
-                RECALC_SIGPENDING;
-                SIGNAL_MASK_UNLOCK(current, flags);
+                cfs_daemonize(name);
         }
-
+        
         complete(&lcq->lcq_comp);
 
         while (1) {
@@ -235,6 +255,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
         struct ll_close_queue *lcq;
         pid_t pid;
 
+        OBD_FAIL_RETURN(OBD_FAIL_LDLM_CLOSE_THREAD, -EINTR);
         OBD_ALLOC(lcq, sizeof(*lcq));
         if (lcq == NULL)
                 return -ENOMEM;