+int lmv_revalidate_slaves(struct obd_export *exp,
+ const struct lu_fid *pfid,
+ const struct lmv_stripe_md *lsm,
+ ldlm_blocking_callback cb_blocking,
+ int extra_lock_flags)
+{
+ struct obd_device *obd = exp->exp_obd;
+ struct lmv_obd *lmv = &obd->u.lmv;
+ struct ptlrpc_request *req = NULL;
+ struct mdt_body *body;
+ struct md_op_data *op_data;
+ int i;
+ int valid_stripe_count = 0;
+ int rc = 0;
+
+ ENTRY;
+
+ /**
+ * revalidate slaves has some problems, temporarily return,
+ * we may not need that
+ */
+ OBD_ALLOC_PTR(op_data);
+ if (op_data == NULL)
+ RETURN(-ENOMEM);
+
+ /**
+ * Loop over the stripe information, check validity and update them
+ * from MDS if needed.
+ */
+ for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
+ struct lu_fid fid;
+ struct lookup_intent it = { .it_op = IT_GETATTR };
+ struct lustre_handle *lockh = NULL;
+ struct lmv_tgt_desc *tgt = NULL;
+ struct inode *inode;
+
+ fid = lsm->lsm_md_oinfo[i].lmo_fid;
+ inode = lsm->lsm_md_oinfo[i].lmo_root;
+
+ if (!inode)
+ continue;
+
+ /*
+ * Prepare op_data for revalidating. Note that @fid2 shluld be
+ * defined otherwise it will go to server and take new lock
+ * which is not needed here.
+ */
+ memset(op_data, 0, sizeof(*op_data));
+ op_data->op_fid1 = *pfid;
+ op_data->op_fid2 = fid;
+
+ tgt = lmv_tgt(lmv, lsm->lsm_md_oinfo[i].lmo_mds);
+ if (!tgt)
+ GOTO(cleanup, rc = -ENODEV);
+
+ CDEBUG(D_INODE, "Revalidate slave "DFID" -> mds #%u\n",
+ PFID(&fid), tgt->ltd_index);
+
+ if (req != NULL) {
+ ptlrpc_req_finished(req);
+ req = NULL;
+ }
+
+ rc = md_intent_lock(tgt->ltd_exp, op_data, &it, &req,
+ cb_blocking, extra_lock_flags);
+ if (rc == -ENOENT) {
+ /* skip stripe is not exists */
+ rc = 0;
+ continue;
+ }
+
+ if (rc < 0)
+ GOTO(cleanup, rc);
+
+ lockh = (struct lustre_handle *)&it.it_lock_handle;
+ if (rc > 0 && req == NULL) {
+ /* slave inode is still valid */
+ CDEBUG(D_INODE, "slave "DFID" is still valid.\n",
+ PFID(&fid));
+ rc = 0;
+ } else {
+ /* refresh slave from server */
+ body = req_capsule_server_get(&req->rq_pill,
+ &RMF_MDT_BODY);
+ if (body == NULL) {
+ if (it.it_lock_mode && lockh) {
+ ldlm_lock_decref(lockh,
+ it.it_lock_mode);
+ it.it_lock_mode = 0;
+ }
+ GOTO(cleanup, rc = -ENOENT);
+ }
+
+ i_size_write(inode, body->mbo_size);
+ inode->i_blocks = body->mbo_blocks;
+ set_nlink(inode, body->mbo_nlink);
+ inode->i_atime.tv_sec = body->mbo_atime;
+ inode->i_ctime.tv_sec = body->mbo_ctime;
+ inode->i_mtime.tv_sec = body->mbo_mtime;
+ }
+
+ md_set_lock_data(tgt->ltd_exp, lockh, inode, NULL);
+ if (it.it_lock_mode != 0 && lockh != NULL) {
+ ldlm_lock_decref(lockh, it.it_lock_mode);
+ it.it_lock_mode = 0;
+ }
+
+ valid_stripe_count++;
+ }
+
+cleanup:
+ if (req != NULL)
+ ptlrpc_req_finished(req);
+
+ /* if all stripes are invalid, return -ENOENT to notify user */
+ if (!rc && !valid_stripe_count)
+ rc = -ENOENT;
+
+ OBD_FREE_PTR(op_data);
+ RETURN(rc);
+}
+