Whamcloud - gitweb
LU-2489 hsm: remove hsm_nl proc file
[fs/lustre-release.git] / lustre / obdclass / llog_osd.c
index e344f00..b1b0bab 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -390,9 +390,10 @@ static int llog_osd_write_rec(const struct lu_env *env,
                        /* We assume that caller has set lgh_cur_* */
                        lgi->lgi_off = loghandle->lgh_cur_offset;
                        CDEBUG(D_OTHER,
-                              "modify record "LPX64": idx:%d/%u/%d, len:%u "
+                              "modify record "DOSTID": idx:%d/%u/%d, len:%u "
                               "offset %llu\n",
-                              loghandle->lgh_id.lgl_oid, idx, rec->lrh_index,
+                              POSTID(&loghandle->lgh_id.lgl_oi), idx,
+                              rec->lrh_index,
                               loghandle->lgh_cur_idx, rec->lrh_len,
                               (long long)(lgi->lgi_off - sizeof(*llh)));
                        if (rec->lrh_index != loghandle->lgh_cur_idx) {
@@ -494,8 +495,8 @@ out:
                                    &lgi->lgi_off, th);
        }
 
-       CDEBUG(D_RPCTRACE, "added record "LPX64": idx: %u, %u\n",
-              loghandle->lgh_id.lgl_oid, index, rec->lrh_len);
+       CDEBUG(D_RPCTRACE, "added record "DOSTID": idx: %u, %u\n",
+              POSTID(&loghandle->lgh_id.lgl_oi), index, rec->lrh_len);
        if (rc == 0 && reccookie) {
                reccookie->lgc_lgl = loghandle->lgh_id;
                reccookie->lgc_index = index;
@@ -606,10 +607,10 @@ static int llog_osd_next_block(const struct lu_env *env,
                        GOTO(out, rc);
 
                if (rc < sizeof(*tail)) {
-                       CERROR("%s: invalid llog block at log id "LPU64"/%u "
+                       CERROR("%s: invalid llog block at log id "DOSTID"/%u "
                               "offset "LPU64"\n",
                               o->do_lu.lo_dev->ld_obd->obd_name,
-                              loghandle->lgh_id.lgl_oid,
+                              POSTID(&loghandle->lgh_id.lgl_oi),
                               loghandle->lgh_id.lgl_ogen, *cur_offset);
                        GOTO(out, rc = -EINVAL);
                }
@@ -632,10 +633,10 @@ static int llog_osd_next_block(const struct lu_env *env,
 
                /* this shouldn't happen */
                if (tail->lrt_index == 0) {
-                       CERROR("%s: invalid llog tail at log id "LPU64"/%u "
+                       CERROR("%s: invalid llog tail at log id "DOSTID"/%u "
                               "offset "LPU64"\n",
                               o->do_lu.lo_dev->ld_obd->obd_name,
-                              loghandle->lgh_id.lgl_oid,
+                              POSTID(&loghandle->lgh_id.lgl_oi),
                               loghandle->lgh_id.lgl_ogen, *cur_offset);
                        GOTO(out, rc = -EINVAL);
                }
@@ -714,10 +715,10 @@ static int llog_osd_prev_block(const struct lu_env *env,
                        GOTO(out, rc);
 
                if (rc < sizeof(*tail)) {
-                       CERROR("%s: invalid llog block at log id "LPU64"/%u "
+                       CERROR("%s: invalid llog block at log id "DOSTID"/%u "
                               "offset "LPU64"\n",
                               o->do_lu.lo_dev->ld_obd->obd_name,
-                              loghandle->lgh_id.lgl_oid,
+                              POSTID(&loghandle->lgh_id.lgl_oi),
                               loghandle->lgh_id.lgl_ogen, cur_offset);
                        GOTO(out, rc = -EINVAL);
                }
@@ -738,10 +739,10 @@ static int llog_osd_prev_block(const struct lu_env *env,
 
                /* this shouldn't happen */
                if (tail->lrt_index == 0) {
-                       CERROR("%s: invalid llog tail at log id "LPU64"/%u "
+                       CERROR("%s: invalid llog tail at log id "DOSTID"/%u "
                               "offset "LPU64"\n",
                               o->do_lu.lo_dev->ld_obd->obd_name,
-                              loghandle->lgh_id.lgl_oid,
+                              POSTID(&loghandle->lgh_id.lgl_oi),
                               loghandle->lgh_id.lgl_ogen, cur_offset);
                        GOTO(out, rc = -EINVAL);
                }
@@ -811,7 +812,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle,
                RETURN(PTR_ERR(ls));
 
        mutex_lock(&ls->ls_los_mutex);
-       los = dt_los_find(ls, FID_SEQ_LLOG);
+       los = dt_los_find(ls, name != NULL ? FID_SEQ_LLOG_NAME : FID_SEQ_LLOG);
        mutex_unlock(&ls->ls_los_mutex);
        LASSERT(los);
        ls_device_put(env, ls);
@@ -917,7 +918,6 @@ static int llog_osd_declare_create(const struct lu_env *env,
                llog_dir = llog_osd_dir_get(env, res->lgh_ctxt);
                if (IS_ERR(llog_dir))
                        RETURN(PTR_ERR(llog_dir));
-               dt_declare_ref_add(env, o, th);
                logid_to_fid(&res->lgh_id, &lgi->lgi_fid);
                rc = dt_declare_insert(env, llog_dir,
                                       (struct dt_rec *)&lgi->lgi_fid,
@@ -959,8 +959,7 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res,
                rc = llog_osd_create_new_object(env, los, o, th);
        else
                rc = -EEXIST;
-       if (res->lgh_name)
-               dt_ref_add(env, o, th);
+
        dt_write_unlock(env, o);
        if (rc)
                RETURN(rc);
@@ -1012,7 +1011,6 @@ static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle)
 static int llog_osd_destroy(const struct lu_env *env,
                            struct llog_handle *loghandle)
 {
-       struct llog_thread_info *lgi = llog_info(env);
        struct llog_ctxt        *ctxt;
        struct dt_object        *o, *llog_dir = NULL;
        struct dt_device        *d;
@@ -1041,7 +1039,6 @@ static int llog_osd_destroy(const struct lu_env *env,
                if (IS_ERR(llog_dir))
                        GOTO(out_trans, rc = PTR_ERR(llog_dir));
 
-               dt_declare_ref_del(env, o, th);
                name = loghandle->lgh_name;
                rc = dt_declare_delete(env, llog_dir,
                                       (struct dt_key *)name, th);
@@ -1062,7 +1059,6 @@ static int llog_osd_destroy(const struct lu_env *env,
        dt_write_lock(env, o, 0);
        if (dt_object_exists(o)) {
                if (name) {
-                       dt_ref_del(env, o, th);
                        dt_read_lock(env, llog_dir, 0);
                        rc = dt_delete(env, llog_dir,
                                       (struct dt_key *) name,
@@ -1075,18 +1071,7 @@ static int llog_osd_destroy(const struct lu_env *env,
                                GOTO(out_unlock, rc);
                        }
                }
-               /*
-                * XXX: compatibility bits
-                *      on old filesystems llogs are referenced by the name
-                *      on the new ones they are referenced by OI and by
-                *      the name
-                */
-               rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL);
-               if (rc)
-                       GOTO(out_unlock, rc);
-               LASSERT(lgi->lgi_attr.la_nlink < 2);
-               if (lgi->lgi_attr.la_nlink == 1)
-                       dt_ref_del(env, o, th);
+               dt_ref_del(env, o, th);
                rc = dt_destroy(env, o, th);
                if (rc)
                        GOTO(out_unlock, rc);
@@ -1124,6 +1109,14 @@ static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd,
        lgi->lgi_fid.f_ver = 0;
        rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
                                    &lgi->lgi_fid, &los);
+       if (rc < 0)
+               return rc;
+
+       lgi->lgi_fid.f_seq = FID_SEQ_LLOG_NAME;
+       lgi->lgi_fid.f_oid = 1;
+       lgi->lgi_fid.f_ver = 0;
+       rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
+                                   &lgi->lgi_fid, &los);
        llog_ctxt_put(ctxt);
        return rc;
 }
@@ -1132,7 +1125,7 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 {
        struct dt_device                *dt;
        struct ls_device                *ls;
-       struct local_oid_storage        *los;
+       struct local_oid_storage        *los, *nlos;
 
        LASSERT(ctxt->loc_exp->exp_obd);
        dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
@@ -1142,11 +1135,16 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 
        mutex_lock(&ls->ls_los_mutex);
        los = dt_los_find(ls, FID_SEQ_LLOG);
+       nlos = dt_los_find(ls, FID_SEQ_LLOG_NAME);
        mutex_unlock(&ls->ls_los_mutex);
        if (los != NULL) {
                dt_los_put(los);
                local_oid_storage_fini(env, los);
        }
+       if (nlos != NULL) {
+               dt_los_put(nlos);
+               local_oid_storage_fini(env, nlos);
+       }
        ls_device_put(env, ls);
        return 0;
 }