X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fllog.c;h=274ba97517d12e9152e3514d981b6952176509a0;hb=bed1cbb3db18e01b933f1a799b4f4fd4ff707cfa;hp=61c9a1d1f4e8ae0148d434c8a31b29f4ba951104;hpb=8da9fb0cf14cc79bf1985d144d0a201e136dfe51;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 61c9a1d..274ba97 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -23,7 +23,7 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2016, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -196,7 +196,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, { struct llog_thread_info *lgi = llog_info(env); struct dt_device *dt; - struct llog_log_hdr *llh = loghandle->lgh_hdr; + struct llog_log_hdr *llh; struct thandle *th; int rc; int rc1; @@ -204,6 +204,12 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, ENTRY; + LASSERT(loghandle != NULL); + LASSERT(loghandle->lgh_ctxt != NULL); + LASSERT(loghandle->lgh_obj != NULL); + + llh = loghandle->lgh_hdr; + CDEBUG(D_RPCTRACE, "Canceling %d in log "DFID"\n", index, PFID(&loghandle->lgh_id.lgl_oi.oi_fid)); @@ -212,10 +218,6 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, RETURN(-EINVAL); } - LASSERT(loghandle != NULL); - LASSERT(loghandle->lgh_ctxt != NULL); - LASSERT(loghandle->lgh_obj != NULL); - dt = lu2dt_dev(loghandle->lgh_obj->do_lu.lo_dev); th = dt_trans_create(env, dt); @@ -419,6 +421,7 @@ static int llog_process_thread(void *arg) struct llog_handle *loghandle = lpi->lpi_loghandle; struct llog_log_hdr *llh = loghandle->lgh_hdr; struct llog_process_cat_data *cd = lpi->lpi_catdata; + struct llog_thread_info *lti; char *buf; size_t chunk_size; __u64 cur_offset; @@ -432,6 +435,8 @@ static int llog_process_thread(void *arg) if (llh == NULL) RETURN(-EINVAL); + lti = lpi->lpi_env == NULL ? NULL : llog_info(lpi->lpi_env); + cur_offset = chunk_size = llh->llh_hdr.lrh_len; /* expect chunk_size to be power of two */ LASSERT(is_power_of_2(chunk_size)); @@ -594,15 +599,37 @@ repeat: rec->lrh_index, rec->lrh_len, (int)(buf + chunk_size - (char *)rec)); - loghandle->lgh_cur_idx = rec->lrh_index; + /* lgh_cur_offset is used only at llog_test_3 */ loghandle->lgh_cur_offset = (char *)rec - (char *)buf + chunk_offset; /* if set, process the callback on this record */ if (ext2_test_bit(index, LLOG_HDR_BITMAP(llh))) { + struct llog_cookie *lgc; + __u64 tmp_off; + int tmp_idx; + + if (lti != NULL) { + lgc = <i->lgi_cookie; + /* store lu_env for recursive calls */ + tmp_off = lgc->lgc_offset; + tmp_idx = lgc->lgc_index; + + lgc->lgc_offset = (char *)rec - + (char *)buf + chunk_offset; + lgc->lgc_index = rec->lrh_index; + } + /* using lu_env for passing record offset to + * llog_write through various callbacks */ rc = lpi->lpi_cb(lpi->lpi_env, loghandle, rec, lpi->lpi_cbdata); last_called_index = index; + + if (lti != NULL) { + lgc->lgc_offset = tmp_off; + lgc->lgc_index = tmp_idx; + } + if (rc == LLOG_PROC_BREAK) { GOTO(out, rc); } else if (rc == LLOG_DEL_RECORD) { @@ -1140,7 +1167,8 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, { struct dt_device *dt; struct thandle *th; - int rc; + bool need_cookie; + int rc; ENTRY; @@ -1163,8 +1191,21 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, if (rc) GOTO(out_trans, rc); + need_cookie = !(idx == LLOG_HEADER_IDX || idx == LLOG_NEXT_IDX); + down_write(&loghandle->lgh_lock); - rc = llog_write_rec(env, loghandle, rec, NULL, idx, th); + if (need_cookie) { + struct llog_thread_info *lti = llog_info(env); + + /* cookie comes from llog_process_thread */ + rc = llog_write_rec(env, loghandle, rec, <i->lgi_cookie, + rec->lrh_index, th); + /* upper layer didn`t pass cookie so change rc */ + rc = (rc == 1 ? 0 : rc); + } else { + rc = llog_write_rec(env, loghandle, rec, NULL, idx, th); + } + up_write(&loghandle->lgh_lock); out_trans: dt_trans_stop(env, dt, th); @@ -1348,8 +1389,9 @@ __u64 llog_size(const struct lu_env *env, struct llog_handle *llh) rc = llh->lgh_obj->do_ops->do_attr_get(env, llh->lgh_obj, &la); if (rc) { - CERROR("%s: attr_get failed, rc = %d\n", - llh->lgh_ctxt->loc_obd->obd_name, rc); + CERROR("%s: attr_get failed for "DFID": rc = %d\n", + llh->lgh_ctxt->loc_obd->obd_name, + PFID(&llh->lgh_id.lgl_oi.oi_fid), rc); return 0; }