X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fllog_osd.c;h=e7ae395e919433b7c7911e382af2da35e25c333a;hb=9126d8159d5d5b61a600e7427d0c173084a710e6;hp=fb8fba4f17cc8ece4c0b3c7ca89d60c28ba438ce;hpb=8248c89371b8d156ab17ea24de5712f7242cdf9e;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/llog_osd.c b/lustre/obdclass/llog_osd.c index fb8fba4..e7ae395 100644 --- a/lustre/obdclass/llog_osd.c +++ b/lustre/obdclass/llog_osd.c @@ -111,6 +111,23 @@ static int llog_osd_create_new_object(const struct lu_env *env, } /** + * Implementation of the llog_operations::lop_exist + * + * This function checks that llog exists on storage. + * + * \param[in] handle llog handle of the current llog + * + * \retval true if llog object exists and is not just destroyed + * \retval false if llog doesn't exist or just destroyed + */ +static int llog_osd_exist(struct llog_handle *handle) +{ + LASSERT(handle->lgh_obj); + return dt_object_exists(handle->lgh_obj) && + !lu_object_is_dying(handle->lgh_obj->do_lu.lo_header); +} + +/** * Write a padding record to the llog * * This function writes a padding record to the end of llog. That may @@ -378,6 +395,9 @@ static int llog_osd_write_rec(const struct lu_env *env, CDEBUG(D_OTHER, "new record %x to "DFID"\n", rec->lrh_type, PFID(lu_object_fid(&o->do_lu))); + if (!llog_osd_exist(loghandle)) + RETURN(-ENOENT); + /* record length should not bigger than */ if (reclen > loghandle->lgh_hdr->llh_hdr.lrh_len) RETURN(-E2BIG); @@ -521,6 +541,14 @@ static int llog_osd_write_rec(const struct lu_env *env, * process them page-at-a-time if needed. If it will cross a chunk * boundary, write in a fake (but referenced) entry to pad the chunk. */ + + + /* simulate ENOSPC when new plain llog is being added to the + * catalog */ + if (OBD_FAIL_CHECK(OBD_FAIL_MDS_LLOG_CREATE_FAILED2) && + llh->llh_flags & LLOG_F_IS_CAT) + RETURN(-ENOSPC); + LASSERT(lgi->lgi_attr.la_valid & LA_SIZE); lgi->lgi_off = lgi->lgi_attr.la_size; left = chunk_size - (lgi->lgi_off & (chunk_size - 1)); @@ -535,7 +563,7 @@ static int llog_osd_write_rec(const struct lu_env *env, } /* if it's the last idx in log file, then return -ENOSPC * or wrap around if a catalog */ - if ((loghandle->lgh_last_idx >= LLOG_HDR_BITMAP_SIZE(llh) - 1) || + if (llog_is_full(loghandle) || unlikely(llh->llh_flags & LLOG_F_IS_CAT && OBD_FAIL_PRECHECK(OBD_FAIL_CAT_RECORDS) && loghandle->lgh_last_idx >= cfs_fail_val)) { @@ -1223,23 +1251,6 @@ out: } /** - * Implementation of the llog_operations::lop_exist - * - * This function checks that llog exists on storage. - * - * \param[in] handle llog handle of the current llog - * - * \retval true if llog object exists and is not just destroyed - * \retval false if llog doesn't exist or just destroyed - */ -static int llog_osd_exist(struct llog_handle *handle) -{ - LASSERT(handle->lgh_obj); - return (dt_object_exists(handle->lgh_obj) && - !lu_object_is_dying(handle->lgh_obj->do_lu.lo_header)); -} - -/** * Get dir for regular fid log object * * Get directory for regular fid log object, and these regular fid log