#include <linux/obd_class.h>
#include <linux/lustre_mds.h>
#include <linux/lustre_dlm.h>
+#include <linux/lustre_snap.h>
#include <linux/lprocfs_status.h>
#include "mdc_internal.h"
/* CREAT needs to be tested before open (both could be set) */
if (it->it_op & IT_CREAT)
return LCK_PW;
- else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP))
+ else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP |
+ IT_CHDIR))
return LCK_PR;
LBUG();
return 0;
}
-
+#if CONFIG_SNAPFS
+int mdc_set_clone_info(struct obd_export *exp, struct lustre_msg *msg,
+ int offset)
+{
+ struct client_obd *cli_obd = &exp->exp_obd->u.cli;
+ struct clonefs_info *cl_info;
+ ENTRY;
+
+ if (cli_obd->cl_clone_info) {
+ cl_info = (struct clonefs_info *)lustre_msg_buf(msg, offset,
+ sizeof (*cl_info));
+ memcpy(cl_info, cli_obd->cl_clone_info, sizeof(*cl_info));
+ }
+ RETURN(0);
+}
+#endif
/* We always reserve enough space in the reply packet for a stripe MD, because
* we don't know in advance the file type. */
/* get ready for the reply */
reply_buffers = 3;
req->rq_replen = lustre_msg_size(3, repsize);
- } else if (it->it_op & IT_UNLINK) {
- size[2] = sizeof(struct mds_rec_unlink);
- size[3] = data->namelen + 1;
- req = ptlrpc_prep_req(class_exp2cliimp(exp), LDLM_ENQUEUE, 4,
- size, NULL);
- if (!req)
- RETURN(-ENOMEM);
-
- /* pack the intent */
- lit = lustre_msg_buf(req->rq_reqmsg, 1, sizeof (*lit));
- lit->opc = (__u64)it->it_op;
-
- /* pack the intended request */
- mdc_unlink_pack(req->rq_reqmsg, 2, data);
- /* get ready for the reply */
- reply_buffers = 4;
- req->rq_replen = lustre_msg_size(4, repsize);
- } else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) {
+ } else if (it->it_op & (IT_GETATTR | IT_LOOKUP | IT_CHDIR)) {
int valid = OBD_MD_FLNOTOBD | OBD_MD_FLEASIZE;
size[2] = sizeof(struct mds_body);
size[3] = data->namelen + 1;
if (it->it_op & IT_GETATTR)
policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
-
+#if CONFIG_SNAPFS
+ size[4] = sizeof(struct clonefs_info);
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LDLM_ENQUEUE, 5,
+ size, NULL);
+#else
req = ptlrpc_prep_req(class_exp2cliimp(exp), LDLM_ENQUEUE, 4,
size, NULL);
+
+#endif
if (!req)
RETURN(-ENOMEM);
/* pack the intended request */
mdc_getattr_pack(req->rq_reqmsg, valid, 2, it->it_flags, data);
+#if CONFIG_SNAPFS
+ mdc_set_clone_info(exp, req->rq_reqmsg, 4);
+#endif
/* get ready for the reply */
reply_buffers = 3;
req->rq_replen = lustre_msg_size(3, repsize);
} else if (it->it_op == IT_READDIR) {
- policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+ policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LDLM_ENQUEUE, 1,
size, NULL);
+
if (!req)
RETURN(-ENOMEM);
-
/* get ready for the reply */
reply_buffers = 1;
req->rq_replen = lustre_msg_size(1, repsize);
- } else {
+ } else if (it->it_op == IT_UNLINK) {
+ size[2] = sizeof(struct mds_body);
+ policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+ req = ptlrpc_prep_req(class_exp2cliimp(exp), LDLM_ENQUEUE, 3,
+ size, NULL);
+ if (!req)
+ RETURN(-ENOMEM);
+
+ /* pack the intended request */
+ mdc_getattr_pack(req->rq_reqmsg, 0, 2, 0, data);
+
+ /* pack the intent */
+ lit = lustre_msg_buf(req->rq_reqmsg, 1, sizeof (*lit));
+ lit->opc = (__u64)it->it_op;
+
+ /* get ready for the reply */
+ reply_buffers = 3;
+ req->rq_replen = lustre_msg_size(3, repsize);
+ } else {
LBUG();
RETURN(-EINVAL);
}
}
if ((body->valid & OBD_MD_FLEASIZE) != 0) {
- void *replayea;
- /* The eadata is opaque; just check that it is
- * there. Eventually, obd_unpackmd() will check
- * the contents */
+ /* The eadata is opaque; just check that it is there.
+ * Eventually, obd_unpackmd() will check the contents */
eadata = lustre_swab_repbuf(req, 2, body->eadatasize,
NULL);
if (eadata == NULL) {
RETURN (-EPROTO);
}
if (it->it_op & IT_OPEN) {
- replayea = lustre_msg_buf(req->rq_reqmsg, 4,
- obddev->u.cli.cl_max_mds_easize);
+ void *replayea;
+
+ replayea = lustre_msg_buf(req->rq_reqmsg, 4,
+ body->eadatasize);
LASSERT(replayea);
memcpy(replayea, eadata, body->eadatasize);
+
+ LASSERT(req->rq_reqmsg->bufcount == 5);
+ req->rq_reqmsg->buflens[4] = body->eadatasize;
+ /* If this isn't the last buffer, we might
+ * have to shift other data around. */
}
}
}
CDEBUG(D_DLMTRACE, "name: %*s in %ld, intent: %s\n", len, name,
pfid ? (unsigned long) pfid->id : 0 , ldlm_it2str(it->it_op));
- if ((it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR) && cfid) {
+ if (cfid && (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR ||
+ it->it_op == IT_CHDIR)) {
/* We could just return 1 immediately, but since we should only
* be called in revalidate_it if we already have a lock, let's
* verify that. */
} else if (it->it_op == IT_OPEN) {
LASSERT(!it_disposition(it, DISP_OPEN_CREATE));
} else {
- LASSERT(it->it_op & (IT_GETATTR | IT_LOOKUP));
+ LASSERT(it->it_op & (IT_GETATTR | IT_LOOKUP | IT_CHDIR));
}
/* If we already have a matching lock, then cancel the new