Whamcloud - gitweb
LU-1994 kernel: fix reference counting with l_dentry_open
[fs/lustre-release.git] / lustre / obdclass / llog_lvfs.c
index e2fc8a3..9373474 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -328,14 +330,14 @@ static int llog_lvfs_write_rec(const struct lu_env *env,
         /*The caller should make sure only 1 process access the lgh_last_idx,
          *Otherwise it might hit the assert.*/
         LASSERT(index < LLOG_BITMAP_SIZE(llh));
-       cfs_spin_lock(&loghandle->lgh_hdr_lock);
+       spin_lock(&loghandle->lgh_hdr_lock);
        if (ext2_set_bit(index, llh->llh_bitmap)) {
                CERROR("argh, index %u already set in log bitmap?\n", index);
-               cfs_spin_unlock(&loghandle->lgh_hdr_lock);
+               spin_unlock(&loghandle->lgh_hdr_lock);
                LBUG(); /* should never happen */
        }
        llh->llh_count++;
-       cfs_spin_unlock(&loghandle->lgh_hdr_lock);
+       spin_unlock(&loghandle->lgh_hdr_lock);
         llh->llh_tail.lrt_index = index;
 
         rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0);
@@ -622,9 +624,9 @@ static int llog_lvfs_open(const struct lu_env *env,  struct llog_handle *handle,
                               logid->lgl_ogen, rc);
                        GOTO(out, rc);
                }
-               /* l_dentry_open will call dput(dchild) if there is an error */
                handle->lgh_file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild,
                                                 O_RDWR | O_LARGEFILE);
+               l_dput(dchild);
                if (IS_ERR(handle->lgh_file)) {
                        rc = PTR_ERR(handle->lgh_file);
                        handle->lgh_file = NULL;
@@ -734,6 +736,7 @@ static int llog_lvfs_create(const struct lu_env *env,
                        GOTO(out, rc = PTR_ERR(dchild));
 
                file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild, open_flags);
+               l_dput(dchild);
                if (IS_ERR(file))
                        GOTO(out, rc = PTR_ERR(file));
                handle->lgh_id.lgl_oseq = oa->o_seq;