1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2003 Cluster File Systems, Inc.
5 * Author: Peter Braam <braam@clusterfs.com>
6 * Author: Andreas Dilger <adilger@clusterfs.com>
7 * Author: Phil Schwan <phil@clusterfs.com>
8 * Author: Mike Shaver <shaver@clusterfs.com>
10 * This file is part of Lustre, http://www.lustre.org.
12 * Lustre is free software; you can redistribute it and/or
13 * modify it under the terms of version 2 of the GNU General Public
14 * License as published by the Free Software Foundation.
16 * Lustre is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with Lustre; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 # define EXPORT_SYMTAB
29 #define DEBUG_SUBSYSTEM S_MDS
31 #include <linux/version.h>
32 #include <linux/module.h>
33 #include <linux/init.h>
34 #include <linux/version.h>
35 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
36 # include <linux/buffer_head.h>
37 # include <linux/workqueue.h>
39 # include <linux/locks.h>
42 #include <linux/obd_class.h>
43 #include <linux/obd_lov.h>
44 #include <linux/lustre_fsfilt.h>
45 #include <linux/lprocfs_status.h>
47 #include "mds_internal.h"
49 /* Exported function from this file are:
51 * mds_open - called by the intent handler
52 * mds_close - an rpc handling function
53 * mds_pin - an rpc handling function - which will go away
54 * mds_mfd_close - for force closing files when a client dies
58 * MDS file data handling: file data holds a handle for a file opened
62 static void mds_mfd_addref(void *mfdp)
64 struct mds_file_data *mfd = mfdp;
66 atomic_inc(&mfd->mfd_refcount);
67 CDEBUG(D_INFO, "GETting mfd %p : new refcount %d\n", mfd,
68 atomic_read(&mfd->mfd_refcount));
71 struct mds_file_data *mds_mfd_new(void)
73 struct mds_file_data *mfd;
75 OBD_ALLOC(mfd, sizeof *mfd);
77 CERROR("mds: out of memory\n");
81 atomic_set(&mfd->mfd_refcount, 2);
83 INIT_LIST_HEAD(&mfd->mfd_handle.h_link);
84 class_handle_hash(&mfd->mfd_handle, mds_mfd_addref);
89 static struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle)
92 LASSERT(handle != NULL);
93 RETURN(class_handle2object(handle->cookie));
96 static void mds_mfd_put(struct mds_file_data *mfd)
98 CDEBUG(D_INFO, "PUTting mfd %p : new refcount %d\n", mfd,
99 atomic_read(&mfd->mfd_refcount) - 1);
100 LASSERT(atomic_read(&mfd->mfd_refcount) > 0 &&
101 atomic_read(&mfd->mfd_refcount) < 0x5a5a);
102 if (atomic_dec_and_test(&mfd->mfd_refcount)) {
103 LASSERT(list_empty(&mfd->mfd_handle.h_link));
104 OBD_FREE(mfd, sizeof *mfd);
108 static void mds_mfd_destroy(struct mds_file_data *mfd)
110 class_handle_unhash(&mfd->mfd_handle);
115 /* Caller must hold mds->mds_epoch_sem */
116 static int mds_alloc_filterdata(struct inode *inode)
118 LASSERT(inode->i_filterdata == NULL);
119 OBD_ALLOC(inode->i_filterdata, sizeof(struct mds_filter_data));
120 if (inode->i_filterdata == NULL)
122 LASSERT(igrab(inode) == inode);
126 /* Caller must hold mds->mds_epoch_sem */
127 static void mds_free_filterdata(struct inode *inode)
129 LASSERT(inode->i_filterdata != NULL);
130 OBD_FREE(inode->i_filterdata, sizeof(struct mds_filter_data));
131 inode->i_filterdata = NULL;
135 /* Write access to a file: executors cause a negative count,
136 * writers a positive count. The semaphore is needed to perform
137 * a check for the sign and then increment or decrement atomically.
139 * This code is closely tied to the allocation of the d_fsdata and the
140 * MDS epoch, so we use the same semaphore for the whole lot.
142 * We could use a different semaphore for each file, if it ever shows
143 * up in a profile, which it won't.
145 * epoch argument is nonzero during recovery */
146 static int mds_get_write_access(struct mds_obd *mds, struct inode *inode,
151 down(&mds->mds_epoch_sem);
153 if (atomic_read(&inode->i_writecount) < 0) {
154 up(&mds->mds_epoch_sem);
159 if (MDS_FILTERDATA(inode) && MDS_FILTERDATA(inode)->io_epoch != 0) {
160 CDEBUG(D_INODE, "continuing MDS epoch "LPU64" for ino %lu/%u\n",
161 MDS_FILTERDATA(inode)->io_epoch, inode->i_ino,
162 inode->i_generation);
166 if (inode->i_filterdata == NULL)
167 mds_alloc_filterdata(inode);
168 if (inode->i_filterdata == NULL) {
172 if (epoch > mds->mds_io_epoch)
173 mds->mds_io_epoch = epoch;
176 MDS_FILTERDATA(inode)->io_epoch = mds->mds_io_epoch;
177 CDEBUG(D_INODE, "starting MDS epoch "LPU64" for ino %lu/%u\n",
178 mds->mds_io_epoch, inode->i_ino, inode->i_generation);
181 atomic_inc(&inode->i_writecount);
182 up(&mds->mds_epoch_sem);
186 /* Returns EAGAIN if the client needs to get size and/or cookies and close
187 * again -- which is never true if the file is about to be unlinked. Otherwise
188 * returns the number of remaining writers. */
189 static int mds_put_write_access(struct mds_obd *mds, struct inode *inode,
190 struct mds_body *body, int unlinking)
195 down(&mds->mds_epoch_sem);
196 atomic_dec(&inode->i_writecount);
197 rc = atomic_read(&inode->i_writecount);
201 if (!unlinking && !(body->valid & OBD_MD_FLSIZE))
202 GOTO(out, rc = EAGAIN);
204 mds_free_filterdata(inode);
206 up(&mds->mds_epoch_sem);
210 static int mds_deny_write_access(struct mds_obd *mds, struct inode *inode)
213 down(&mds->mds_epoch_sem);
214 if (atomic_read(&inode->i_writecount) > 0) {
215 up(&mds->mds_epoch_sem);
218 atomic_dec(&inode->i_writecount);
219 up(&mds->mds_epoch_sem);
223 static void mds_allow_write_access(struct inode *inode)
226 atomic_inc(&inode->i_writecount);
229 int mds_query_write_access(struct inode *inode)
232 RETURN(atomic_read(&inode->i_writecount));
235 /* This replaces the VFS dentry_open, it manages mfd and writecount */
236 static struct mds_file_data *mds_dentry_open(struct dentry *dentry,
237 struct vfsmount *mnt, int flags,
238 struct ptlrpc_request *req)
240 struct mds_export_data *med = &req->rq_export->exp_mds_data;
241 struct mds_obd *mds = mds_req2mds(req);
242 struct mds_file_data *mfd;
243 struct mds_body *body;
249 CERROR("mds: out of memory\n");
250 GOTO(cleanup_dentry, error = -ENOMEM);
253 body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
255 if (flags & FMODE_WRITE) {
256 /* FIXME: in recovery, need to pass old epoch here */
257 error = mds_get_write_access(mds, dentry->d_inode, 0);
259 GOTO(cleanup_mfd, error);
260 body->io_epoch = MDS_FILTERDATA(dentry->d_inode)->io_epoch;
261 } else if (flags & FMODE_EXEC) {
262 error = mds_deny_write_access(mds, dentry->d_inode);
264 GOTO(cleanup_mfd, error);
269 /* Mark the file as open to handle open-unlink. */
270 MDS_DOWN_WRITE_ORPHAN_SEM(dentry->d_inode);
271 mds_orphan_open_inc(dentry->d_inode);
272 MDS_UP_WRITE_ORPHAN_SEM(dentry->d_inode);
274 mfd->mfd_mode = flags;
275 mfd->mfd_dentry = dentry;
276 mfd->mfd_xid = req->rq_xid;
278 spin_lock(&med->med_open_lock);
279 list_add(&mfd->mfd_list, &med->med_open_head);
280 spin_unlock(&med->med_open_lock);
283 body->handle.cookie = mfd->mfd_handle.h_cookie;
289 mds_mfd_destroy(mfd);
291 return ERR_PTR(error);
294 /* Must be called with i_sem held */
295 static int mds_create_objects(struct ptlrpc_request *req, int offset,
296 struct mds_update_record *rec,
297 struct mds_obd *mds, struct obd_device *obd,
298 struct dentry *dchild, void **handle, obd_id **ids,
299 struct llog_cookie **ret_logcookies,
300 int *setattr_async_flag)
303 struct obd_trans_info oti = { 0 };
304 struct mds_body *body;
305 struct lov_stripe_md *lsm = NULL;
306 struct lov_mds_md *lmm = NULL;
307 struct inode *inode = dchild->d_inode;
309 int rc, lmm_bufsize, lmm_size;
312 if (rec->ur_flags & MDS_OPEN_DELAY_CREATE ||
313 !(rec->ur_flags & FMODE_WRITE))
316 body = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*body));
318 if (!S_ISREG(inode->i_mode))
320 if (body->valid & OBD_MD_FLEASIZE)
323 OBD_ALLOC(*ids, mds->mds_lov_desc.ld_tgt_count * sizeof(**ids));
326 oti.oti_objid = *ids;
329 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
330 if (rec->ur_fid2->id == 0) {
331 DEBUG_REQ(D_ERROR, req, "fid2 not set on open replay");
335 body->valid |= OBD_MD_FLBLKSZ | OBD_MD_FLEASIZE;
336 lmm_size = rec->ur_eadatalen;
337 lmm = rec->ur_eadata;
341 *handle = fsfilt_start(obd,inode,FSFILT_OP_CREATE,NULL);
342 if (IS_ERR(*handle)) {
343 rc = PTR_ERR(*handle);
348 mds_objids_from_lmm(*ids, lmm, &mds->mds_lov_desc);
350 lmm_buf = lustre_msg_buf(req->rq_repmsg, offset, 0);
351 lmm_bufsize = req->rq_repmsg->buflens[offset];
353 LASSERT(lmm_bufsize >= lmm_size);
354 memcpy(lmm_buf, lmm, lmm_size);
355 rc = fsfilt_set_md(obd, inode, *handle, lmm, lmm_size);
357 CERROR("open replay failed to set md:%d\n", rc);
361 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO))
362 GOTO(out_ids, rc = -ENOMEM);
366 GOTO(out_ids, rc = -ENOMEM);
367 oa->o_mode = S_IFREG | 0600;
368 oa->o_id = inode->i_ino;
369 oa->o_generation = inode->i_generation;
370 oa->o_uid = 0; /* must have 0 uid / gid on OST */
372 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLTYPE |
373 OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID;
376 obdo_from_inode(oa, inode, OBD_MD_FLTYPE|OBD_MD_FLATIME|OBD_MD_FLMTIME|
379 if (!(rec->ur_flags & MDS_OPEN_HAS_OBJS)) {
380 /* check if things like lfs setstripe are sending us the ea */
381 if (rec->ur_flags & MDS_OPEN_HAS_EA) {
382 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
384 0, &lsm, rec->ur_eadata);
388 OBD_ALLOC(lmm, mds->mds_max_mdsize);
390 GOTO(out_oa, rc = -ENOMEM);
392 lmm_size = mds->mds_max_mdsize;
393 rc = mds_get_md(obd, dchild->d_parent->d_inode,
396 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
399 OBD_FREE(lmm, mds->mds_max_mdsize);
403 rc = obd_create(mds->mds_osc_exp, oa, &lsm, &oti);
408 CDEBUG(level, "error creating objects for "
409 "inode %lu: rc = %d\n",
412 CERROR("obd_create returned invalid "
418 *setattr_async_flag = 1;
420 rc = obd_iocontrol(OBD_IOC_LOV_SETEA, mds->mds_osc_exp,
421 0, &lsm, rec->ur_eadata);
425 lsm->lsm_object_id = oa->o_id;
428 oa->o_size = inode->i_size;
429 obdo_from_inode(oa, inode, OBD_MD_FLTYPE|OBD_MD_FLATIME|
430 OBD_MD_FLMTIME| OBD_MD_FLCTIME| OBD_MD_FLSIZE);
431 rc = obd_setattr(mds->mds_osc_exp, oa, lsm, &oti);
433 CERROR("error setting attrs for inode %lu: rc %d\n",
436 CERROR("obd_setattr returned bad rc %d\n", rc);
443 body->valid |= OBD_MD_FLBLKSZ | OBD_MD_FLEASIZE;
444 obdo_refresh_inode(inode, oa, OBD_MD_FLBLKSZ);
446 LASSERT(lsm && lsm->lsm_object_id);
448 rc = obd_packmd(mds->mds_osc_exp, &lmm, lsm);
451 body->eadatasize = rc;
453 if (*handle == NULL) {
454 if (*setattr_async_flag)
455 *handle = fsfilt_start_log(obd, inode,
456 FSFILT_OP_CREATE, NULL,
457 le32_to_cpu(lmm->lmm_stripe_count));
459 *handle = fsfilt_start(obd, inode, FSFILT_OP_CREATE, NULL);
461 if (IS_ERR(*handle)) {
462 rc = PTR_ERR(*handle);
467 /* write mds setattr log for created objects */
468 if (*setattr_async_flag && lmm_size) {
469 struct llog_cookie *logcookies = NULL;
471 OBD_ALLOC(logcookies, mds->mds_max_cookiesize);
472 if (logcookies == NULL)
473 GOTO(out_oa, rc = -ENOMEM);
474 *ret_logcookies = logcookies;
475 if (mds_log_op_setattr(obd, inode, lmm, lmm_size, logcookies,
476 mds->mds_max_cookiesize) <= 0) {
477 OBD_FREE(logcookies, mds->mds_max_cookiesize);
478 *ret_logcookies = NULL;
482 rc = fsfilt_set_md(obd, inode, *handle, lmm, lmm_size);
483 lmm_buf = lustre_msg_buf(req->rq_repmsg, offset, 0);
484 lmm_bufsize = req->rq_repmsg->buflens[offset];
486 LASSERT(lmm_bufsize >= lmm_size);
488 memcpy(lmm_buf, lmm, lmm_size);
489 obd_free_diskmd(mds->mds_osc_exp, &lmm);
491 oti_free_cookies(&oti);
495 OBD_FREE(*ids, mds->mds_lov_desc.ld_tgt_count * sizeof(**ids));
499 obd_free_memmd(mds->mds_osc_exp, &lsm);
503 static void reconstruct_open(struct mds_update_record *rec, int offset,
504 struct ptlrpc_request *req,
505 struct lustre_handle *child_lockh)
507 struct mds_export_data *med = &req->rq_export->exp_mds_data;
508 struct mds_client_data *mcd = med->med_mcd;
509 struct mds_obd *mds = mds_req2mds(req);
510 struct mds_file_data *mfd;
511 struct obd_device *obd = req->rq_export->exp_obd;
512 struct dentry *parent, *dchild;
513 struct ldlm_reply *rep;
514 struct mds_body *body;
520 LASSERT(offset == 2); /* only called via intent */
521 rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep));
522 body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
524 /* copy rc, transno and disp; steal locks */
525 mds_req_from_mcd(req, mcd);
526 intent_set_disposition(rep, mcd->mcd_last_data);
528 /* Only replay if create or open actually happened. */
529 if (!intent_disposition(rep, DISP_OPEN_CREATE | DISP_OPEN_OPEN) ) {
531 return; /* error looking up parent or child */
534 parent = mds_fid2dentry(mds, rec->ur_fid1, NULL);
535 LASSERT(!IS_ERR(parent));
537 dchild = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1);
538 LASSERT(!IS_ERR(dchild));
540 if (!dchild->d_inode)
541 GOTO(out_dput, 0); /* child not present to open */
543 /* At this point, we know we have a child. We'll send
544 * it back _unless_ it not created and open failed.
546 if (intent_disposition(rep, DISP_OPEN_OPEN) &&
547 !intent_disposition(rep, DISP_OPEN_CREATE) &&
552 mds_pack_inode2fid(&body->fid1, dchild->d_inode);
553 mds_pack_inode2body(body, dchild->d_inode);
554 if (S_ISREG(dchild->d_inode->i_mode)) {
555 rc = mds_pack_md(obd, req->rq_repmsg, 2, body,
559 LASSERT(rc == req->rq_status);
561 /* If we have LOV EA data, the OST holds size, mtime */
562 if (!(body->valid & OBD_MD_FLEASIZE))
563 body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
564 OBD_MD_FLATIME | OBD_MD_FLMTIME);
567 /* If we have -EEXIST as the status, and we were asked to create
568 * exclusively, we can tell we failed because the file already existed.
570 if (req->rq_status == -EEXIST &&
571 ((rec->ur_flags & (MDS_OPEN_CREAT | MDS_OPEN_EXCL)) ==
572 (MDS_OPEN_CREAT | MDS_OPEN_EXCL))) {
576 /* If we didn't get as far as trying to open, then some locking thing
577 * probably went wrong, and we'll just bail here.
579 if (!intent_disposition(rep, DISP_OPEN_OPEN))
582 /* If we failed, then we must have failed opening, so don't look for
583 * file descriptor or anything, just give the client the bad news.
589 list_for_each(t, &med->med_open_head) {
590 mfd = list_entry(t, struct mds_file_data, mfd_list);
591 if (mfd->mfd_xid == req->rq_xid)
596 /* #warning "XXX fixme" bug 2991 */
597 /* Here it used to LASSERT(mfd) if exp_outstanding_reply != NULL.
598 * Now that exp_outstanding_reply is a list, it's just using mfd != NULL
599 * to detect a re-open */
601 mntget(mds->mds_vfsmnt);
602 CERROR("Re-opened file \n");
603 mfd = mds_dentry_open(dchild, mds->mds_vfsmnt,
604 rec->ur_flags & ~MDS_OPEN_TRUNC, req);
606 CERROR("mds: out of memory\n");
607 GOTO(out_dput, req->rq_status = -ENOMEM);
611 body->handle.cookie = mfd->mfd_handle.h_cookie;
612 CDEBUG(D_INODE, "resend mfd %p, cookie "LPX64"\n", mfd,
613 mfd->mfd_handle.h_cookie);
623 /* do NOT or the MAY_*'s, you'll get the weakest */
624 static int accmode(struct inode *inode, int flags)
628 /* Sadly, NFSD reopens a file repeatedly during operation, so the
629 * "acc_mode = 0" allowance for newly-created files isn't honoured.
630 * NFSD uses the MDS_OPEN_OWNEROVERRIDE flag to say that a file
631 * owner can write to a file even if it is marked readonly to hide
632 * its brokenness. (bug 5781) */
633 if (flags & MDS_OPEN_OWNEROVERRIDE && inode->i_uid == current->fsuid)
636 if (flags & FMODE_READ)
638 if (flags & (FMODE_WRITE|MDS_OPEN_TRUNC))
640 if (flags & FMODE_EXEC)
645 /* Handles object creation, actual opening, and I/O epoch */
646 static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
647 struct mds_body *body, int flags, void **handle,
648 struct mds_update_record *rec,struct ldlm_reply *rep,
649 struct llog_cookie **logcookies,
650 int *setattr_async_flag)
652 struct mds_obd *mds = mds_req2mds(req);
653 struct obd_device *obd = req->rq_export->exp_obd;
654 struct mds_file_data *mfd = NULL;
655 obd_id *ids = NULL; /* object IDs created */
659 /* atomically create objects if necessary */
660 down(&dchild->d_inode->i_sem);
661 if (S_ISREG(dchild->d_inode->i_mode) &&
662 !(body->valid & OBD_MD_FLEASIZE)) {
663 rc = mds_pack_md(obd, req->rq_repmsg, 2, body,
666 up(&dchild->d_inode->i_sem);
671 if ((body->valid & OBD_MD_FLEASIZE) &&
672 (rec->ur_flags & MDS_OPEN_HAS_EA)) {
673 up(&dchild->d_inode->i_sem);
677 if (!(body->valid & OBD_MD_FLEASIZE)) {
678 /* no EA: create objects */
679 rc = mds_create_objects(req, 2, rec, mds, obd,
680 dchild, handle, &ids,
681 logcookies, setattr_async_flag);
683 CERROR("mds_create_objects: rc = %d\n", rc);
684 up(&dchild->d_inode->i_sem);
689 /* If the inode has no EA data, then MDS holds size, mtime */
690 if (S_ISREG(dchild->d_inode->i_mode) &&
691 !(body->valid & OBD_MD_FLEASIZE)) {
692 body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
693 OBD_MD_FLATIME | OBD_MD_FLMTIME);
695 up(&dchild->d_inode->i_sem);
697 intent_set_disposition(rep, DISP_OPEN_OPEN);
698 mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, flags, req);
700 RETURN(PTR_ERR(mfd));
702 CDEBUG(D_INODE, "mfd %p, cookie "LPX64"\n", mfd,
703 mfd->mfd_handle.h_cookie);
705 mds_lov_update_objids(obd, ids);
706 OBD_FREE(ids, sizeof(*ids) * mds->mds_lov_desc.ld_tgt_count);
709 // mds_mfd_destroy(mfd);
713 static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid,
714 struct mds_body *body, int flags,
715 struct mds_update_record *rec,struct ldlm_reply *rep)
717 struct obd_device *obd = req->rq_export->exp_obd;
718 struct mds_obd *mds = mds_req2mds(req);
719 struct dentry *dchild;
720 char fidname[LL_FID_NAMELEN];
723 struct llog_cookie *logcookies = NULL;
724 struct lov_mds_md *lmm = NULL;
726 int setattr_async_flag = 0;
729 fidlen = ll_fid2str(fidname, fid->id, fid->generation);
730 dchild = ll_lookup_one_len(fidname, mds->mds_pending_dir, fidlen);
731 if (IS_ERR(dchild)) {
732 rc = PTR_ERR(dchild);
733 CERROR("error looking up %s in PENDING: rc = %d\n",fidname, rc);
737 if (dchild->d_inode != NULL) {
738 mds_inode_set_orphan(dchild->d_inode);
739 mds_pack_inode2fid(&body->fid1, dchild->d_inode);
740 mds_pack_inode2body(body, dchild->d_inode);
741 intent_set_disposition(rep, DISP_LOOKUP_EXECD);
742 intent_set_disposition(rep, DISP_LOOKUP_POS);
743 CWARN("Orphan %s found and opened in PENDING directory\n",
749 /* We didn't find it in PENDING so it isn't an orphan. See
750 * if it was a regular inode that was previously created. */
751 dchild = mds_fid2dentry(mds, fid, NULL);
753 RETURN(PTR_ERR(dchild));
755 mds_pack_inode2fid(&body->fid1, dchild->d_inode);
756 mds_pack_inode2body(body, dchild->d_inode);
757 intent_set_disposition(rep, DISP_LOOKUP_EXECD);
758 intent_set_disposition(rep, DISP_LOOKUP_POS);
761 rc = mds_finish_open(req, dchild, body, flags, &handle, rec, rep,
762 &logcookies, &setattr_async_flag);
763 rc = mds_finish_transno(mds, dchild ? dchild->d_inode : NULL, handle,
764 req, rc, rep ? rep->lock_policy_res1 : 0);
765 /* do mds to ost setattr for new created objects */
766 if (rc == 0 && setattr_async_flag) {
767 lmm = lustre_msg_buf(req->rq_repmsg, 2, 0);
768 lmm_size = req->rq_repmsg->buflens[2];
769 rc = mds_osc_setattr_async(obd, dchild->d_inode, lmm, lmm_size,
772 /* XXX what do we do here if mds_finish_transno itself failed? */
778 int mds_pin(struct ptlrpc_request *req)
780 struct obd_device *obd = req->rq_export->exp_obd;
781 struct mds_body *request_body, *reply_body;
782 struct obd_run_ctxt saved;
783 int rc, size = sizeof(*reply_body);
786 request_body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*request_body));
788 rc = lustre_pack_reply(req, 1, &size, NULL);
791 reply_body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply_body));
793 push_ctxt(&saved, &obd->obd_ctxt, NULL);
794 rc = mds_open_by_fid(req, &request_body->fid1, reply_body,
795 request_body->flags, NULL, NULL);
796 pop_ctxt(&saved, &obd->obd_ctxt, NULL);
801 /* Get a lock on the ino to sync with creation WRT inode reuse (bug 2029).
802 * If child_lockh is NULL we just get the lock as a barrier to wait for
803 * other holders of this lock, and drop it right away again. */
804 int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
805 struct lustre_handle *child_lockh)
807 struct ldlm_res_id child_res_id = { .name = { inode->i_ino, 0, 1, 0 } };
808 struct lustre_handle lockh;
812 if (child_lockh == NULL)
813 child_lockh = &lockh;
815 rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, child_res_id,
816 LDLM_PLAIN, NULL, LCK_EX, &lock_flags,
817 mds_blocking_ast, ldlm_completion_ast, NULL, NULL,
818 NULL, 0, NULL, child_lockh);
820 CERROR("ldlm_cli_enqueue: %d\n", rc);
821 else if (child_lockh == &lockh)
822 ldlm_lock_decref(child_lockh, LCK_EX);
827 int mds_open(struct mds_update_record *rec, int offset,
828 struct ptlrpc_request *req, struct lustre_handle *child_lockh)
830 /* XXX ALLOCATE _something_ - 464 bytes on stack here */
831 struct obd_device *obd = req->rq_export->exp_obd;
832 struct mds_obd *mds = mds_req2mds(req);
833 struct ldlm_reply *rep = NULL;
834 struct mds_body *body = NULL;
835 struct dentry *dchild = NULL, *dparent = NULL;
836 struct mds_export_data *med;
837 struct lustre_handle parent_lockh;
838 int rc = 0, cleanup_phase = 0, acc_mode, created = 0;
839 int parent_mode = LCK_PR;
841 struct dentry_params dp;
842 struct lov_mds_md *lmm = NULL;
844 struct llog_cookie *logcookies = NULL;
845 int setattr_async_flag = 0;
846 uid_t parent_uid = 0;
847 gid_t parent_gid = 0;
850 if (offset == 2) { /* intent */
851 rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep));
852 body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
853 } else if (offset == 0) { /* non-intent reint */
854 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
860 MDS_CHECK_RESENT(req, reconstruct_open(rec, offset, req, child_lockh));
862 /* Step 0: If we are passed a fid, then we assume the client already
863 * opened this file and is only replaying the RPC, so we open the
864 * inode by fid (at some large expense in security). */
865 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
866 if (rec->ur_fid2->id == 0) {
867 struct ldlm_lock *lock = ldlm_handle2lock(child_lockh);
869 LDLM_ERROR(lock, "fid2 not set on open replay");
872 DEBUG_REQ(D_ERROR, req, "fid2 not set on open replay");
876 rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags,
881 /* We didn't find the correct inode on disk either, so we
882 * need to re-create it via a regular replay. */
883 if (!(rec->ur_flags & MDS_OPEN_CREAT)) {
884 DEBUG_REQ(D_ERROR, req,"OPEN_CREAT not in open replay");
887 } else if (rec->ur_fid2->id) {
888 DEBUG_REQ(D_ERROR, req, "fid2 "LPU64"/%u on open non-replay",
889 rec->ur_fid2->id, rec->ur_fid2->generation);
893 LASSERT(offset == 2); /* If we got here, we must be called via intent */
895 med = &req->rq_export->exp_mds_data;
896 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK)) {
897 CERROR("test case OBD_FAIL_MDS_OPEN_PACK\n");
901 /* Step 1: Find and lock the parent */
902 if (rec->ur_flags & MDS_OPEN_CREAT)
903 parent_mode = LCK_PW;
904 dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, parent_mode,
905 &parent_lockh, rec->ur_name,
906 rec->ur_namelen - 1);
907 if (IS_ERR(dparent)) {
908 rc = PTR_ERR(dparent);
910 CERROR("parent "LPU64"/%u lookup error %d\n",
911 rec->ur_fid1->id, rec->ur_fid1->generation, rc);
913 /* Just cannot find parent - make it look like
914 * usual negative lookup to avoid extra MDS RPC */
915 intent_set_disposition(rep, DISP_LOOKUP_EXECD);
916 intent_set_disposition(rep, DISP_LOOKUP_NEG);
920 LASSERT(dparent->d_inode != NULL);
922 cleanup_phase = 1; /* parent dentry and lock */
924 /* Step 2: Lookup the child */
925 dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1);
926 if (IS_ERR(dchild)) {
927 rc = PTR_ERR(dchild);
928 dchild = NULL; /* don't confuse mds_finish_transno() below */
932 cleanup_phase = 2; /* child dentry */
934 intent_set_disposition(rep, DISP_LOOKUP_EXECD);
936 intent_set_disposition(rep, DISP_LOOKUP_POS);
938 intent_set_disposition(rep, DISP_LOOKUP_NEG);
940 /*Step 3: If the child was negative, and we're supposed to, create it.*/
941 if (dchild->d_inode == NULL) {
942 unsigned long ino = rec->ur_fid2->id;
946 if (!(rec->ur_flags & MDS_OPEN_CREAT)) {
947 /* It's negative and we weren't supposed to create it */
948 GOTO(cleanup, rc = -ENOENT);
951 if (req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY)
952 GOTO(cleanup, rc = -EROFS);
954 intent_set_disposition(rep, DISP_OPEN_CREATE);
955 handle = fsfilt_start(obd, dparent->d_inode, FSFILT_OP_CREATE,
957 if (IS_ERR(handle)) {
958 rc = PTR_ERR(handle);
962 dchild->d_fsdata = (void *) &dp;
966 rc = ll_vfs_create(dparent->d_inode, dchild, rec->ur_mode,NULL);
967 if (dchild->d_fsdata == (void *)(unsigned long)ino)
968 dchild->d_fsdata = NULL;
971 CDEBUG(D_INODE, "error during create: %d\n", rc);
974 inode = dchild->d_inode;
976 LASSERT(ino == inode->i_ino);
977 /* Written as part of setattr */
978 inode->i_generation = rec->ur_fid2->generation;
979 CDEBUG(D_HA, "recreated ino %lu with gen %u\n",
980 inode->i_ino, inode->i_generation);
984 LTIME_S(iattr.ia_atime) = rec->ur_time;
985 LTIME_S(iattr.ia_ctime) = rec->ur_time;
986 LTIME_S(iattr.ia_mtime) = rec->ur_time;
988 iattr.ia_uid = rec->ur_fsuid;
989 if (dparent->d_inode->i_mode & S_ISGID)
990 iattr.ia_gid = dparent->d_inode->i_gid;
992 iattr.ia_gid = rec->ur_fsgid;
994 iattr.ia_valid = ATTR_UID | ATTR_GID | ATTR_ATIME |
995 ATTR_MTIME | ATTR_CTIME;
997 rc = fsfilt_setattr(obd, dchild, handle, &iattr, 0);
999 CERROR("error on child setattr: rc = %d\n", rc);
1001 iattr.ia_valid = ATTR_MTIME | ATTR_CTIME;
1003 rc = fsfilt_setattr(obd, dparent, handle, &iattr, 0);
1005 CERROR("error on parent setattr: rc = %d\n", rc);
1007 rc = fsfilt_commit(obd, dchild->d_inode, handle, 0);
1009 acc_mode = 0; /* Don't check for permissions */
1011 acc_mode = accmode(dchild->d_inode, rec->ur_flags);
1015 LASSERTF(!mds_inode_is_orphan(dchild->d_inode),
1016 "dchild %.*s (%p) inode %p\n", dchild->d_name.len,
1017 dchild->d_name.name, dchild, dchild->d_inode);
1019 mds_pack_inode2fid(&body->fid1, dchild->d_inode);
1020 mds_pack_inode2body(body, dchild->d_inode);
1022 if (S_ISREG(dchild->d_inode->i_mode)) {
1023 /* Check permissions etc */
1024 rc = ll_permission(dchild->d_inode, acc_mode, NULL);
1028 if ((req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY) &&
1029 (acc_mode & MAY_WRITE))
1030 GOTO(cleanup, rc = -EROFS);
1032 /* Can't write to a read-only file */
1033 if (IS_RDONLY(dchild->d_inode) && (acc_mode & MAY_WRITE) != 0)
1034 GOTO(cleanup, rc = -EPERM);
1036 /* An append-only file must be opened in append mode for
1038 if (IS_APPEND(dchild->d_inode) && (acc_mode & MAY_WRITE) != 0 &&
1039 ((rec->ur_flags & MDS_OPEN_APPEND) == 0 ||
1040 (rec->ur_flags & MDS_OPEN_TRUNC) != 0))
1041 GOTO(cleanup, rc = -EPERM);
1044 if (!created && (rec->ur_flags & MDS_OPEN_CREAT) &&
1045 (rec->ur_flags & MDS_OPEN_EXCL)) {
1046 /* File already exists, we didn't just create it, and we
1047 * were passed O_EXCL; err-or. */
1048 GOTO(cleanup, rc = -EEXIST); // returns a lock to the client
1051 /* if we are following a symlink, don't open */
1052 if (S_ISLNK(dchild->d_inode->i_mode))
1053 GOTO(cleanup_no_trans, rc = 0);
1055 if (S_ISDIR(dchild->d_inode->i_mode)) {
1056 if (rec->ur_flags & MDS_OPEN_CREAT ||
1057 rec->ur_flags & FMODE_WRITE) {
1058 /* we are trying to create or write a exist dir */
1059 GOTO(cleanup, rc = -EISDIR);
1061 if (ll_permission(dchild->d_inode, acc_mode, NULL)) {
1062 intent_set_disposition(rep, DISP_OPEN_OPEN);
1063 GOTO(cleanup, rc = -EACCES);
1065 } else if (rec->ur_flags & MDS_OPEN_DIRECTORY) {
1066 GOTO(cleanup, rc = -ENOTDIR);
1069 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_CREATE)) {
1070 obd_fail_loc = OBD_FAIL_LDLM_REPLY | OBD_FAIL_ONCE;
1071 GOTO(cleanup, rc = -EAGAIN);
1074 /* Step 5: mds_open it */
1075 rc = mds_finish_open(req, dchild, body, rec->ur_flags, &handle, rec,
1076 rep, &logcookies, &setattr_async_flag);
1080 rc = mds_finish_transno(mds, dchild ? dchild->d_inode : NULL, handle,
1081 req, rc, rep ? rep->lock_policy_res1 : 0);
1082 /* do mds to ost setattr for new created objects */
1083 if (rc == 0 && setattr_async_flag) {
1084 lmm = lustre_msg_buf(req->rq_repmsg, 2, 0);
1085 lmm_size = req->rq_repmsg->buflens[2];
1086 mds_osc_setattr_async(obd, dchild->d_inode, lmm, lmm_size,
1091 switch (cleanup_phase) {
1093 if (rc && created) {
1094 int err = vfs_unlink(dparent->d_inode, dchild);
1096 CERROR("unlink(%.*s) in error path: %d\n",
1097 dchild->d_name.len, dchild->d_name.name,
1100 } else if (created) {
1101 mds_lock_new_child(obd, dchild->d_inode, NULL);
1102 /* save uid/gid for quota acquire/release */
1103 parent_uid = dparent->d_inode->i_uid;
1104 parent_gid = dparent->d_inode->i_gid;
1109 if (dparent == NULL)
1114 ldlm_lock_decref(&parent_lockh, parent_mode);
1116 ptlrpc_save_lock (req, &parent_lockh, parent_mode);
1119 /* trigger dqacq on the owner of child and parent */
1120 mds_adjust_qunit(obd, current->fsuid, current->fsgid,
1121 parent_uid, parent_gid, rc);
1125 /* Close a "file descriptor" and possibly unlink an orphan from the
1126 * PENDING directory. Caller must hold child->i_sem, this drops it.
1128 * If we are being called from mds_disconnect() because the client has
1129 * disappeared, then req == NULL and we do not update last_rcvd because
1130 * there is nothing that could be recovered by the client at this stage
1131 * (it will not even _have_ an entry in last_rcvd anymore).
1133 * Returns EAGAIN if the client needs to get more data and re-close. */
1134 int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd,
1135 struct mds_file_data *mfd, int unlink_orphan)
1137 struct inode *inode = mfd->mfd_dentry->d_inode;
1138 char fidname[LL_FID_NAMELEN];
1139 int last_orphan, fidlen, rc = 0, cleanup_phase = 0;
1140 struct dentry *pending_child = NULL;
1141 struct mds_obd *mds = &obd->u.mds;
1142 struct inode *pending_dir = mds->mds_pending_dir->d_inode;
1143 void *handle = NULL;
1144 struct mds_body *request_body = NULL, *reply_body = NULL;
1145 struct dentry_params dp;
1146 struct iattr iattr = { 0 };
1149 if (req && req->rq_reqmsg != NULL)
1150 request_body = lustre_msg_buf(req->rq_reqmsg, 0,
1151 sizeof(*request_body));
1152 if (req && req->rq_repmsg != NULL)
1153 reply_body = lustre_msg_buf(req->rq_repmsg, 0,
1154 sizeof(*reply_body));
1156 fidlen = ll_fid2str(fidname, inode->i_ino, inode->i_generation);
1158 CDEBUG(D_INODE, "inode %p ino %s nlink %d orphan %d\n", inode, fidname,
1159 inode->i_nlink, mds_orphan_open_count(inode));
1161 last_orphan = mds_orphan_open_dec_test(inode) &&
1162 mds_inode_is_orphan(inode);
1163 MDS_UP_WRITE_ORPHAN_SEM(inode);
1165 /* this is half of the actual "close" */
1166 if (mfd->mfd_mode & FMODE_WRITE) {
1167 rc = mds_put_write_access(mds, inode, request_body,
1168 last_orphan && unlink_orphan);
1169 } else if (mfd->mfd_mode & FMODE_EXEC) {
1170 mds_allow_write_access(inode);
1173 if (last_orphan && unlink_orphan) {
1174 struct lov_mds_md *lmm = NULL;
1175 int stripe_count = 0;
1176 LASSERT(rc == 0); /* mds_put_write_access must have succeeded */
1178 CDEBUG(D_HA, "destroying orphan object %s\n", fidname);
1180 if ((S_ISREG(inode->i_mode) && inode->i_nlink != 1) ||
1181 (S_ISDIR(inode->i_mode) && inode->i_nlink != 2))
1182 CERROR("found \"orphan\" %s %s with link count %d\n",
1183 S_ISREG(inode->i_mode) ? "file" : "dir",
1184 fidname, inode->i_nlink);
1186 /* Sadly, there is no easy way to save pending_child from
1187 * mds_reint_unlink() into mfd, so we need to re-lookup,
1188 * but normally it will still be in the dcache. */
1189 down(&pending_dir->i_sem);
1190 cleanup_phase = 1; /* up(&pending_dir->i_sem) when finished */
1191 pending_child = lookup_one_len(fidname, mds->mds_pending_dir,
1193 if (IS_ERR(pending_child))
1194 GOTO(cleanup, rc = PTR_ERR(pending_child));
1195 LASSERT(pending_child->d_inode != NULL);
1197 cleanup_phase = 2; /* dput(pending_child) when finished */
1198 if (S_ISDIR(pending_child->d_inode->i_mode)) {
1199 rc = vfs_rmdir(pending_dir, pending_child);
1201 CERROR("error unlinking orphan dir %s: rc %d\n",
1206 if (req != NULL && req->rq_repmsg != NULL) {
1207 lmm = lustre_msg_buf(req->rq_repmsg, 1, 0);
1208 stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
1211 handle = fsfilt_start_log(obd, pending_dir, FSFILT_OP_UNLINK,
1212 NULL, stripe_count);
1213 if (IS_ERR(handle)) {
1214 rc = PTR_ERR(handle);
1219 if (req != NULL && req->rq_repmsg != NULL &&
1220 (reply_body->valid & OBD_MD_FLEASIZE) &&
1221 mds_log_op_unlink(obd, pending_child->d_inode, lmm,
1222 req->rq_repmsg->buflens[1],
1223 lustre_msg_buf(req->rq_repmsg, 2, 0),
1224 req->rq_repmsg->buflens[2]) > 0) {
1225 reply_body->valid |= OBD_MD_FLCOOKIE;
1228 pending_child->d_fsdata = (void *) &dp;
1231 rc = vfs_unlink(pending_dir, pending_child);
1233 CERROR("error unlinking orphan %s: rc %d\n",fidname,rc);
1235 goto out; /* Don't bother updating attrs on unlinked inode */
1239 if (request_body != NULL && mfd->mfd_mode & FMODE_WRITE && rc == 0) {
1240 /* Update the on-disk attributes if this was the last write
1241 * close, and all information was provided (i.e., rc == 0)
1243 * XXX this should probably be abstracted with mds_reint_setattr
1246 if (request_body->valid & OBD_MD_FLMTIME &&
1247 LTIME_S(iattr.ia_mtime) > LTIME_S(inode->i_mtime)) {
1248 LTIME_S(iattr.ia_mtime) = request_body->mtime;
1249 iattr.ia_valid |= ATTR_MTIME;
1251 if (request_body->valid & OBD_MD_FLCTIME &&
1252 LTIME_S(iattr.ia_ctime) > LTIME_S(inode->i_ctime)) {
1253 LTIME_S(iattr.ia_ctime) = request_body->ctime;
1254 iattr.ia_valid |= ATTR_CTIME;
1257 /* XXX can't set block count with fsfilt_setattr (!) */
1258 if (request_body->valid & OBD_MD_FLSIZE) {
1259 iattr.ia_valid |= ATTR_SIZE;
1260 iattr.ia_size = request_body->size;
1262 /* iattr.ia_blocks = request_body->blocks */
1266 if (request_body != NULL && request_body->valid & OBD_MD_FLATIME) {
1267 /* Only start a transaction to write out only the atime if
1268 * it is more out-of-date than the specified limit. If we
1269 * are already going to write out the atime then do it anyway.
1271 LTIME_S(iattr.ia_atime) = request_body->atime;
1272 if ((LTIME_S(iattr.ia_atime) >
1273 LTIME_S(inode->i_atime) + MAX_ATIME_DIFF) ||
1274 (iattr.ia_valid != 0 &&
1275 LTIME_S(iattr.ia_atime) > LTIME_S(inode->i_atime)))
1276 iattr.ia_valid |= ATTR_ATIME;
1279 if (iattr.ia_valid != 0) {
1280 handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR, NULL);
1282 GOTO(cleanup, rc = PTR_ERR(handle));
1283 rc = fsfilt_setattr(obd, mfd->mfd_dentry, handle, &iattr, 0);
1285 CERROR("error in setattr(%s): rc %d\n", fidname, rc);
1288 /* If other clients have this file open for write, rc will be > 0 */
1291 l_dput(mfd->mfd_dentry);
1292 mds_mfd_destroy(mfd);
1295 if (req != NULL && reply_body != NULL) {
1296 rc = mds_finish_transno(mds, pending_dir, handle, req, rc, 0);
1297 } else if (handle) {
1298 int err = fsfilt_commit(obd, pending_dir, handle, 0);
1300 CERROR("error committing close: %d\n", err);
1306 switch (cleanup_phase) {
1308 dput(pending_child);
1310 up(&pending_dir->i_sem);
1315 int mds_close(struct ptlrpc_request *req)
1317 struct mds_export_data *med = &req->rq_export->exp_mds_data;
1318 struct obd_device *obd = req->rq_export->exp_obd;
1319 struct mds_body *body;
1320 struct mds_file_data *mfd;
1321 struct obd_run_ctxt saved;
1322 struct inode *inode;
1323 int rc, repsize[3] = {sizeof(struct mds_body),
1324 obd->u.mds.mds_max_mdsize,
1325 obd->u.mds.mds_max_cookiesize};
1328 rc = lustre_pack_reply(req, 3, repsize, NULL);
1330 CERROR("lustre_pack_reply: rc = %d\n", rc);
1331 req->rq_status = rc;
1333 MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
1336 body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
1338 CERROR("Can't unpack body\n");
1339 req->rq_status = -EFAULT;
1343 if (body->flags & MDS_BFLAG_UNCOMMITTED_WRITES)
1344 /* do some stuff */ ;
1346 mfd = mds_handle2mfd(&body->handle);
1348 DEBUG_REQ(D_ERROR, req, "no handle for file close ino "LPD64
1349 ": cookie "LPX64, body->fid1.id, body->handle.cookie);
1350 req->rq_status = -ESTALE;
1354 inode = mfd->mfd_dentry->d_inode;
1355 /* child orphan sem protects orphan_dec_test && is_orphan race */
1356 MDS_DOWN_WRITE_ORPHAN_SEM(inode); /* mds_mfd_close drops this */
1357 if (mds_inode_is_orphan(inode) && mds_orphan_open_count(inode) == 1) {
1358 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body));
1359 LASSERT(body != NULL);
1361 mds_pack_inode2fid(&body->fid1, inode);
1362 mds_pack_inode2body(body, inode);
1363 mds_pack_md(obd, req->rq_repmsg, 1,body,inode,MDS_PACK_MD_LOCK);
1365 spin_lock(&med->med_open_lock);
1366 list_del(&mfd->mfd_list);
1367 spin_unlock(&med->med_open_lock);
1369 push_ctxt(&saved, &obd->obd_ctxt, NULL);
1370 req->rq_status = mds_mfd_close(req, obd, mfd, 1);
1371 pop_ctxt(&saved, &obd->obd_ctxt, NULL);
1374 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK)) {
1375 CERROR("test case OBD_FAIL_MDS_CLOSE_PACK\n");
1376 req->rq_status = -ENOMEM;
1383 int mds_done_writing(struct ptlrpc_request *req)
1385 struct mds_body *body;
1386 int rc, size = sizeof(struct mds_body);
1389 MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
1391 body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
1393 CERROR("Can't unpack body\n");
1394 req->rq_status = -EFAULT;
1398 rc = lustre_pack_reply(req, 1, &size, NULL);
1400 CERROR("lustre_pack_reply: rc = %d\n", rc);
1401 req->rq_status = rc;