-/*
- * 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).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
+// SPDX-License-Identifier: GPL-2.0
+
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2012, 2017, Intel Corporation.
*/
+
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/ofd/ofd_lvb.c
*
* This file contains methods for OBD Filter Device (OFD)
* Lock Value Block (LVB) operations.
*/
static int ofd_lvbo_free(struct ldlm_resource *res)
{
- if (res->lr_lvb_data)
- OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
+ OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
return 0;
}
+static bool ofd_resync_allowed(struct ofd_device *ofd)
+{
+ struct obd_device *obd = ofd_obd(ofd);
+
+ if (obd->obd_recovery_start == 0)
+ return false;
+
+ if (obd->obd_recovery_start + obd->obd_recovery_time_hard <
+ ktime_get_seconds())
+ return false;
+
+ return true;
+}
+
/**
* Implementation of ldlm_valblock_ops::lvbo_init for OFD.
*
* \retval 0 on successful setup
* \retval negative value on error
*/
-static int ofd_lvbo_init(const struct lu_env *env, struct ldlm_resource *res)
+static int ofd_lvbo_init(struct ldlm_resource *res)
{
struct ost_lvb *lvb;
struct ofd_device *ofd;
struct ofd_object *fo;
struct ofd_thread_info *info;
- struct lu_env _env;
+ struct lu_env *env;
int rc = 0;
ENTRY;
ofd = ldlm_res_to_ns(res)->ns_lvbp;
LASSERT(ofd != NULL);
- if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_OST_LVB))
+ if (CFS_FAIL_CHECK(OBD_FAIL_LDLM_OST_LVB))
RETURN(-ENOMEM);
- if (!env) {
- rc = lu_env_init(&_env, LCT_DT_THREAD);
- if (rc)
- RETURN(rc);
- env = &_env;
- }
+ env = lu_env_find();
+ LASSERT(env);
OBD_ALLOC_PTR(lvb);
if (lvb == NULL)
info = ofd_info(env);
res->lr_lvb_data = lvb;
+ BUILD_BUG_ON(sizeof(*lvb) >= 1 << (sizeof(res->lr_lvb_len) * 8 - 1));
res->lr_lvb_len = sizeof(*lvb);
ost_fid_from_resid(&info->fti_fid, &res->lr_name,
oseq = ofd_seq_load(env, ofd, fid_seq_is_idif(seq) ?
FID_SEQ_OST_MDT0 : seq);
if (!IS_ERR_OR_NULL(oseq)) {
- if (!oseq->os_last_id_synced)
- rc = -EAGAIN;
+ if (!oseq->os_last_id_synced &&
+ ofd_resync_allowed(ofd))
+ rc = -EINPROGRESS;
ofd_seq_put(env, oseq);
}
}
lvb->lvb_atime = info->fti_attr.la_atime;
lvb->lvb_ctime = info->fti_attr.la_ctime;
- CDEBUG(D_DLMTRACE, "res: "DFID" initial lvb size: %llu, "
- "mtime: %#llx, blocks: %#llx\n",
- PFID(&info->fti_fid), lvb->lvb_size,
- lvb->lvb_mtime, lvb->lvb_blocks);
+ if (fo->ofo_atime_ondisk == 0)
+ fo->ofo_atime_ondisk = info->fti_attr.la_atime;
+
+ CDEBUG(D_DLMTRACE,
+ "res: "DFID" initial LVB size: %llu, mtime: %#llx, atime: %#llx, ctime: %#llx, blocks: %#llx\n",
+ PFID(&info->fti_fid), lvb->lvb_size, lvb->lvb_mtime,
+ lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks);
info->fti_attr.la_valid = 0;
OST_LVB_SET_ERR(lvb->lvb_blocks, rc);
out:
/* Don't free lvb data on lookup error */
- if (env && env == &_env)
- lu_env_fini(&_env);
return rc;
}
* \retval 0 on successful setup
* \retval negative value on error
*/
-static int ofd_lvbo_update(const struct lu_env *env, struct ldlm_resource *res,
- struct ldlm_lock *lock, struct ptlrpc_request *req,
- int increase_only)
+static int ofd_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
+ struct ptlrpc_request *req, int increase_only)
{
- struct ofd_thread_info *info;
- struct ofd_device *ofd;
- struct ofd_object *fo;
- struct ost_lvb *lvb;
- int rc = 0;
+ struct ofd_thread_info *info;
+ struct ofd_device *ofd;
+ struct ofd_object *fo;
+ struct ost_lvb *lvb;
+ const struct lu_env *env;
+ int rc = 0;
ENTRY;
+ env = lu_env_find();
LASSERT(env);
info = ofd_info(env);
LASSERT(res != NULL);
}
unlock_res(res);
+ info->fti_attr.la_valid = 0;
out_obj:
ofd_object_put(env, fo);
out:
*
* \retval size of LVB data written into \a buf buffer
*/
-static int ofd_lvbo_fill(const struct lu_env *env, struct ldlm_lock *lock,
- void *buf, int *buflen)
+static int ofd_lvbo_fill(struct ldlm_lock *lock, void *buf, int *buflen)
{
struct ldlm_resource *res = lock->l_resource;
int lvb_len;