Whamcloud - gitweb
add changelog section for 1.8.3
[fs/lustre-release.git] / lustre / llite / llite_close.c
index 69c98b2..27ce889 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_mdc.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)
 {
@@ -108,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
  *
@@ -122,8 +138,8 @@ static void ll_close_done_writing(struct inode *inode)
         struct ll_inode_info *lli = ll_i2info(inode);
         ldlm_policy_data_t policy = { .l_extent = {0, OBD_OBJECT_EOF } };
         struct lustre_handle lockh = { 0 };
-        struct md_op_data op_data;
-        struct obdo obdo;
+        struct obdo obdo = { 0 };
+        struct mdc_op_data data = { { 0 } };
         obd_flag valid;
         int rc, ast_flags = 0;
         ENTRY;
@@ -141,7 +157,7 @@ static void ll_close_done_writing(struct inode *inode)
                 GOTO(out, rc);
         }
 
-        rc = ll_lsm_getattr(ll_i2dtexp(inode), lli->lli_smd, &obdo);
+        rc = ll_lsm_getattr(ll_i2obdexp(inode), lli->lli_smd, &obdo);
         if (rc) {
                 CERROR("inode_getattr failed (%d): unable to send DONE_WRITING "
                        "for inode %lu/%u\n", rc, inode->i_ino,
@@ -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);
 
@@ -163,15 +179,16 @@ static void ll_close_done_writing(struct inode *inode)
                 CERROR("unlock failed (%d)?  proceeding anyways...\n", rc);
 
  rpc:
-        op_data.fid1 = lli->lli_fid;
-        op_data.size = inode->i_size;
-        op_data.blocks = inode->i_blocks;
-        op_data.valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+        obdo.o_id = inode->i_ino;
+        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_md_exp, &op_data);
+        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");
-                libcfs_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;