1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light Super operations
6 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DEBUG_SUBSYSTEM S_LLITE
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/random.h>
29 #include <linux/version.h>
31 #include <linux/lustre_lite.h>
32 #include <linux/lustre_ha.h>
33 #include <linux/lustre_dlm.h>
34 #include <linux/lprocfs_status.h>
35 #include "llite_internal.h"
37 kmem_cache_t *ll_file_data_slab;
39 extern struct address_space_operations ll_aops;
40 extern struct address_space_operations ll_dir_aops;
43 #define log2(n) ffz(~(n))
46 struct ll_sb_info *lustre_init_sbi(struct super_block *sb)
48 struct ll_sb_info *sbi = NULL;
52 OBD_ALLOC(sbi, sizeof(*sbi));
56 spin_lock_init(&sbi->ll_lock);
57 INIT_LIST_HEAD(&sbi->ll_pglist);
58 sbi->ll_pglist_gen = 0;
59 sbi->ll_max_read_ahead_pages = SBI_DEFAULT_RA_MAX;
60 INIT_LIST_HEAD(&sbi->ll_conn_chain);
61 INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
62 INIT_LIST_HEAD(&sbi->ll_mnt_list);
63 sema_init(&sbi->ll_gns_sem, 1);
64 init_completion(&sbi->ll_gns_completion);
65 sbi->ll_gns_state = LL_GNS_STATE_IDLE;
66 sbi->ll_gns_timer.data = (unsigned long)sbi;
67 sbi->ll_gns_timer.function = ll_gns_timer_callback;
68 init_timer(&sbi->ll_gns_timer);
69 INIT_LIST_HEAD(&sbi->ll_gns_sbi_head);
73 generate_random_uuid(uuid);
74 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
78 void lustre_free_sbi(struct super_block *sb)
80 struct ll_sb_info *sbi = ll_s2sbi(sb);
84 list_del(&sbi->ll_gns_sbi_head);
85 del_timer(&sbi->ll_gns_timer);
86 OBD_FREE(sbi, sizeof(*sbi));
92 int lustre_init_ea_size(struct ll_sb_info *sbi)
97 /* OSC may have larger ea size */
98 valsize = sizeof(desc);
99 rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc",
102 obd_init_ea_size(sbi->ll_mdc_exp,
103 obd_size_diskmd(sbi->ll_osc_exp, NULL),
104 desc.ld_tgt_count*sizeof(struct llog_cookie));
106 /* declare ourself as real client. not connection
108 * FIXME: remove fake valsize, mdsize --bzzz */
109 rc = obd_set_info(sbi->ll_mdc_exp, strlen("client"),
110 "client", valsize, &desc);
115 int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
117 struct inode *root = 0;
118 struct ll_sb_info *sbi = ll_s2sbi(sb);
119 struct obd_device *obd;
120 struct ll_fid rootfid;
121 struct obd_statfs osfs;
122 struct ptlrpc_request *request = NULL;
123 struct lustre_handle osc_conn = {0, };
124 struct lustre_handle mdc_conn = {0, };
129 obd = class_name2obd(mdc);
131 CERROR("MDC %s: not setup or attached\n", mdc);
135 if (proc_lustre_fs_root) {
136 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
139 CERROR("could not register mount in /proc/lustre");
142 err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid);
144 CERROR("An MDS (mdc %s) is performing recovery, of which this"
145 " client is not a part. Please wait for recovery to "
146 "complete, abort, or time out.\n", mdc);
149 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
152 sbi->ll_mdc_exp = class_conn2export(&mdc_conn);
154 err = obd_statfs(obd, &osfs, jiffies - HZ);
158 LASSERT(osfs.os_bsize);
159 sb->s_blocksize = osfs.os_bsize;
160 sb->s_blocksize_bits = log2(osfs.os_bsize);
161 sb->s_magic = LL_SUPER_MAGIC;
162 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
164 devno = get_uuid2int(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid,
165 strlen(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid));
169 obd = class_name2obd(osc);
171 CERROR("OSC %s: not setup or attached\n", osc);
175 err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid);
177 CERROR("An OST (osc %s) is performing recovery, of which this"
178 " client is not a part. Please wait for recovery to "
179 "complete, abort, or time out.\n", osc);
182 CERROR("cannot connect to %s: rc = %d\n", osc, err);
185 sbi->ll_osc_exp = class_conn2export(&osc_conn);
187 lustre_init_ea_size(sbi);
189 err = md_getstatus(sbi->ll_mdc_exp, &rootfid);
191 CERROR("cannot mds_connect: rc = %d\n", err);
194 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
195 sbi->ll_rootino = rootfid.id;
197 sb->s_op = &lustre_super_operations;
200 * XXX: move this to after cbd setup? */
201 err = md_getattr(sbi->ll_mdc_exp, &rootfid,
202 OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS, 0, &request);
204 CERROR("md_getattr failed for root: rc = %d\n", err);
208 err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0,
209 sbi->ll_osc_exp, &md);
211 CERROR("failed to understand root inode md: rc = %d\n",err);
212 ptlrpc_req_finished (request);
216 LASSERT(sbi->ll_rootino != 0);
217 root = ll_iget(sb, sbi->ll_rootino, &md);
219 ptlrpc_req_finished(request);
221 if (root == NULL || is_bad_inode(root)) {
222 /* XXX might need iput() for bad inode */
223 CERROR("lustre_lite: bad iget4 for root\n");
224 GOTO(out_root, err = -EBADF);
227 err = ll_close_thread_start(&sbi->ll_lcq);
229 CERROR("cannot start close thread: rc %d\n", err);
233 ll_gns_add_timer(sbi);
235 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x,
236 backing dev info assigned to inode mapping is used for
237 determining maximal readahead. */
238 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
239 /* bug 2805 - set VM readahead to zero */
240 vm_max_readahead = vm_min_readahead = 0;
243 sb->s_root = d_alloc_root(root);
250 obd_disconnect(sbi->ll_osc_exp, 0);
252 obd_disconnect(sbi->ll_mdc_exp, 0);
254 lprocfs_unregister_mountpoint(sbi);
258 void lustre_common_put_super(struct super_block *sb)
260 struct ll_sb_info *sbi = ll_s2sbi(sb);
261 struct hlist_node *tmp, *next;
264 ll_gns_del_timer(sbi);
266 ll_close_thread_shutdown(sbi->ll_lcq);
268 list_del(&sbi->ll_conn_chain);
269 obd_disconnect(sbi->ll_osc_exp, 0);
271 lprocfs_unregister_mountpoint(sbi);
272 if (sbi->ll_proc_root) {
273 lprocfs_remove(sbi->ll_proc_root);
274 sbi->ll_proc_root = NULL;
277 obd_disconnect(sbi->ll_mdc_exp, 0);
279 // We do this to get rid of orphaned dentries. That is not really trw.
280 spin_lock(&dcache_lock);
281 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
282 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
283 CWARN("orphan dentry %*s (%p) at unmount\n",
284 dentry->d_name.len, dentry->d_name.name, dentry);
285 shrink_dcache_parent(dentry);
287 spin_unlock(&dcache_lock);
292 char *ll_read_opt(const char *opt, char *data)
298 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
299 if (strncmp(opt, data, strlen(opt)))
301 if ((value = strchr(data, '=')) == NULL)
305 OBD_ALLOC(retval, strlen(value) + 1);
307 CERROR("out of memory!\n");
311 memcpy(retval, value, strlen(value)+1);
312 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
316 int ll_set_opt(const char *opt, char *data, int fl)
320 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
321 if (strncmp(opt, data, strlen(opt)))
327 void ll_options(char *options, char **ost, char **mdc, int *flags)
330 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
331 char *opt_ptr = options;
340 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
341 for (this_char = strtok (options, ",");
343 this_char = strtok (NULL, ",")) {
345 while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
347 CDEBUG(D_SUPER, "this_char %s\n", this_char);
348 if (!*ost && (*ost = ll_read_opt("osc", this_char)))
350 if (!*mdc && (*mdc = ll_read_opt("mdc", this_char)))
352 if (!(*flags & LL_SBI_NOLCK) &&
353 ((*flags) = (*flags) |
354 ll_set_opt("nolock", this_char,
361 void ll_lli_init(struct ll_inode_info *lli)
363 sema_init(&lli->lli_open_sem, 1);
365 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
366 spin_lock_init(&lli->lli_lock);
367 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
370 int ll_fill_super(struct super_block *sb, void *data, int silent)
372 struct ll_sb_info *sbi;
378 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
380 sbi = lustre_init_sbi(sb);
384 sbi->ll_flags |= LL_SBI_READAHEAD;
385 ll_options(data, &osc, &mdc, &sbi->ll_flags);
389 GOTO(out, err = -EINVAL);
394 GOTO(out, err = -EINVAL);
397 err = lustre_common_fill_super(sb, mdc, osc);
403 OBD_FREE(mdc, strlen(mdc) + 1);
405 OBD_FREE(osc, strlen(osc) + 1);
408 } /* ll_read_super */
410 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
411 struct config_llog_instance *cfg, int allow_recov)
413 struct lustre_cfg lcfg;
414 struct portals_cfg pcfg;
415 char * peer = "MDS_PEER_UUID";
416 struct obd_device *obd;
417 struct lustre_handle mdc_conn = {0, };
418 struct obd_export *exp;
419 char * name = "mdc_dev";
421 struct obd_uuid mdc_uuid;
422 struct llog_ctxt *ctxt;
427 if (lmd_bad_magic(lmd))
430 generate_random_uuid(uuid);
431 class_uuid_unparse(uuid, &mdc_uuid);
433 if (lmd->lmd_local_nid) {
434 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
435 pcfg.pcfg_nal = lmd->lmd_nal;
436 pcfg.pcfg_nid = lmd->lmd_local_nid;
437 err = libcfs_nal_cmd(&pcfg);
442 if (lmd->lmd_nal == SOCKNAL) {
443 PCFG_INIT(pcfg, NAL_CMD_ADD_AUTOCONN);
444 pcfg.pcfg_nal = lmd->lmd_nal;
445 pcfg.pcfg_nid = lmd->lmd_server_nid;
446 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
447 pcfg.pcfg_misc = lmd->lmd_port;
448 pcfg.pcfg_size = 8388608;
449 pcfg.pcfg_flags = 0x4; /*share*/
450 err = libcfs_nal_cmd(&pcfg);
455 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
456 lcfg.lcfg_nid = lmd->lmd_server_nid;
457 lcfg.lcfg_inllen1 = strlen(peer) + 1;
458 lcfg.lcfg_inlbuf1 = peer;
459 lcfg.lcfg_nal = lmd->lmd_nal;
460 err = class_process_config(&lcfg);
462 GOTO(out_del_conn, err);
464 LCFG_INIT(lcfg, LCFG_ATTACH, name);
465 lcfg.lcfg_inlbuf1 = "mdc";
466 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
467 lcfg.lcfg_inlbuf2 = mdc_uuid.uuid;
468 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
469 err = class_process_config(&lcfg);
471 GOTO(out_del_uuid, err);
473 LCFG_INIT(lcfg, LCFG_SETUP, name);
474 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
475 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
476 lcfg.lcfg_inlbuf2 = peer;
477 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
478 err = class_process_config(&lcfg);
480 GOTO(out_detach, err);
482 obd = class_name2obd(name);
484 GOTO(out_cleanup, err = -EINVAL);
486 /* Disable initial recovery on this import */
487 err = obd_set_info(obd->obd_self_export,
488 strlen("initial_recov"), "initial_recov",
489 sizeof(allow_recov), &allow_recov);
491 GOTO(out_cleanup, err);
493 err = obd_connect(&mdc_conn, obd, &mdc_uuid);
495 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
496 GOTO(out_cleanup, err);
499 exp = class_conn2export(&mdc_conn);
501 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
502 rc = class_config_process_llog(ctxt, profile, cfg);
504 CERROR("class_config_process_llog failed: rc = %d\n", rc);
506 err = obd_disconnect(exp, 0);
509 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
510 err = class_process_config(&lcfg);
515 LCFG_INIT(lcfg, LCFG_DETACH, name);
516 err = class_process_config(&lcfg);
521 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
522 lcfg.lcfg_inllen1 = strlen(peer) + 1;
523 lcfg.lcfg_inlbuf1 = peer;
524 err = class_process_config(&lcfg);
527 if (lmd->lmd_nal == SOCKNAL) {
528 PCFG_INIT(pcfg, NAL_CMD_DEL_AUTOCONN);
529 pcfg.pcfg_nal = lmd->lmd_nal;
530 pcfg.pcfg_nid = lmd->lmd_server_nid;
531 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
532 pcfg.pcfg_flags = 1; /*share*/
533 err = libcfs_nal_cmd(&pcfg);
544 int lustre_fill_super(struct super_block *sb, void *data, int silent)
546 struct lustre_mount_data * lmd = data;
547 struct ll_sb_info *sbi;
553 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
554 if (lmd_bad_magic(lmd))
557 sbi = lustre_init_sbi(sb);
561 sbi->ll_flags |= LL_SBI_READAHEAD;
563 if (lmd->lmd_profile) {
564 struct lustre_profile *lprof;
565 struct config_llog_instance cfg;
568 if (lmd->lmd_mds[0] == '\0') {
569 CERROR("no mds name\n");
570 GOTO(out_free, err = -EINVAL);
573 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
574 if (sbi->ll_lmd == NULL)
575 GOTO(out_free, err = -ENOMEM);
576 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
578 /* generate a string unique to this super, let's try
579 the address of the super itself.*/
580 len = (sizeof(sb) * 2) + 1;
581 OBD_ALLOC(sbi->ll_instance, len);
582 if (sbi->ll_instance == NULL)
583 GOTO(out_free, err = -ENOMEM);
584 sprintf(sbi->ll_instance, "%p", sb);
586 cfg.cfg_instance = sbi->ll_instance;
587 cfg.cfg_uuid = sbi->ll_sb_uuid;
588 cfg.cfg_local_nid = lmd->lmd_local_nid;
589 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
591 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
595 lprof = class_get_profile(lmd->lmd_profile);
597 CERROR("No profile found: %s\n", lmd->lmd_profile);
598 GOTO(out_free, err = -EINVAL);
601 OBD_FREE(osc, strlen(osc) + 1);
602 OBD_ALLOC(osc, strlen(lprof->lp_osc) +
603 strlen(sbi->ll_instance) + 2);
604 sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance);
607 OBD_FREE(mdc, strlen(mdc) + 1);
608 OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
609 strlen(sbi->ll_instance) + 2);
610 sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance);
615 GOTO(out_free, err = -EINVAL);
620 GOTO(out_free, err = -EINVAL);
623 err = lustre_common_fill_super(sb, mdc, osc);
630 OBD_FREE(mdc, strlen(mdc) + 1);
632 OBD_FREE(osc, strlen(osc) + 1);
638 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
641 if (sbi->ll_instance != NULL) {
642 struct lustre_mount_data *lmd = sbi->ll_lmd;
644 struct config_llog_instance cfg;
646 cfg.cfg_instance = sbi->ll_instance;
647 cfg.cfg_uuid = sbi->ll_sb_uuid;
649 OBD_ALLOC(cln_prof, len);
650 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
652 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
654 CERROR("Unable to process log: %s\n", cln_prof);
655 OBD_FREE(cln_prof, len);
656 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
658 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
663 } /* lustre_fill_super */
665 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
667 struct lustre_cfg lcfg;
668 struct obd_device *obd;
671 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
675 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
676 err = class_process_config(&lcfg);
678 CERROR("cleanup failed: %s\n", obd->obd_name);
682 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
683 err = class_process_config(&lcfg);
685 CERROR("detach failed: %s\n", obd->obd_name);
690 if (sbi->ll_lmd != NULL)
691 class_del_profile(sbi->ll_lmd->lmd_profile);
694 void lustre_put_super(struct super_block *sb)
696 struct obd_device *obd;
697 struct ll_sb_info *sbi = ll_s2sbi(sb);
698 int force_umount = 0;
701 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
702 obd = class_exp2obd(sbi->ll_mdc_exp);
704 force_umount = obd->obd_no_recov;
707 lustre_common_put_super(sb);
709 if (sbi->ll_lmd != NULL) {
711 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
713 struct config_llog_instance cfg;
716 CERROR("force umount, doing manual cleanup\n");
717 lustre_manual_cleanup(sbi);
721 cfg.cfg_instance = sbi->ll_instance;
722 cfg.cfg_uuid = sbi->ll_sb_uuid;
724 OBD_ALLOC(cln_prof, len);
725 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
727 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
729 CERROR("Unable to process log: %s, doing manual cleanup"
731 lustre_manual_cleanup(sbi);
734 OBD_FREE(cln_prof, len);
736 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
737 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
743 } /* lustre_put_super */
745 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
747 struct obd_export *mdc_exp = sbi->ll_mdc_exp;
748 struct lustre_mount_data *lmd = sbi->ll_lmd;
749 struct llog_ctxt *ctxt;
750 struct config_llog_instance cfg;
751 char *profile = lmd->lmd_profile, *name = NULL;
752 int rc, namelen = 0, version;
758 CERROR("Client not mounted with zero-conf; cannot process "
763 rc = ldlm_cli_cancel_unused(mdc_exp->exp_obd->obd_namespace, NULL,
764 LDLM_FL_CONFIG_CHANGE, NULL);
766 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
768 rc = obd_cancel_unused(sbi->ll_osc_exp, NULL, LDLM_FL_CONFIG_CHANGE,
771 CWARN("obd_cancel_unused(lov): %d\n", rc);
773 cfg.cfg_instance = sbi->ll_instance;
774 cfg.cfg_uuid = sbi->ll_sb_uuid;
775 cfg.cfg_local_nid = lmd->lmd_local_nid;
777 namelen = strlen(profile) + 20; /* -clean-######### */
778 OBD_ALLOC(name, namelen);
783 version = sbi->ll_config_version - 1;
784 sprintf(name, "%s-clean-%d", profile, version);
786 version = sbi->ll_config_version + 1;
787 sprintf(name, "%s-%d", profile, version);
790 CWARN("Applying configuration log %s\n", name);
792 ctxt = llog_get_context(&mdc_exp->exp_obd->obd_llogs,
793 LLOG_CONFIG_REPL_CTXT);
794 rc = class_config_process_llog(ctxt, name, &cfg);
796 sbi->ll_config_version = version;
797 CWARN("Finished applying configuration log %s: %d\n", name, rc);
799 if (rc == 0 && clean == 0) {
800 struct lov_desc desc;
802 valsize = sizeof(desc);
803 rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1,
804 "lovdesc", &valsize, &desc);
806 rc = obd_init_ea_size(mdc_exp,
807 obd_size_diskmd(sbi->ll_osc_exp, NULL),
809 sizeof(struct llog_cookie)));
811 OBD_FREE(name, namelen);
815 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
818 l_lock(&lock->l_resource->lr_namespace->ns_lock);
819 if (lock->l_ast_data)
820 inode = igrab(lock->l_ast_data);
823 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
827 int null_if_equal(struct ldlm_lock *lock, void *data)
829 if (data == lock->l_ast_data)
830 lock->l_ast_data = NULL;
832 if (lock->l_req_mode != lock->l_granted_mode)
833 return LDLM_ITER_STOP;
835 return LDLM_ITER_CONTINUE;
838 void ll_clear_inode(struct inode *inode)
841 struct ll_inode_info *lli = ll_i2info(inode);
842 struct ll_sb_info *sbi = ll_i2sbi(inode);
845 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
846 inode->i_generation, inode);
848 ll_inode2fid(&fid, inode);
849 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
850 md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
853 obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
854 null_if_equal, inode);
857 obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd);
862 /* FIXME: change cbdata for mea here */
863 obd_free_memmd(sbi->ll_mdc_exp,
864 (struct lov_stripe_md **) &lli->lli_mea);
868 if (lli->lli_symlink_name) {
869 OBD_FREE(lli->lli_symlink_name,
870 strlen(lli->lli_symlink_name) + 1);
871 lli->lli_symlink_name = NULL;
877 /* If this inode has objects allocated to it (lsm != NULL), then the OST
878 * object(s) determine the file size and mtime. Otherwise, the MDS will
879 * keep these values until such a time that objects are allocated for it.
880 * We do the MDS operations first, as it is checking permissions for us.
881 * We don't to the MDS RPC if there is nothing that we want to store there,
882 * otherwise there is no harm in updating mtime/atime on the MDS if we are
883 * going to do an RPC anyways.
885 * If we are doing a truncate, we will send the mtime and ctime updates
886 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
887 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
890 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
892 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
893 struct ll_sb_info *sbi = ll_i2sbi(inode);
894 struct ptlrpc_request *request = NULL;
895 struct mdc_op_data op_data;
896 int ia_valid = attr->ia_valid;
900 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
901 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
903 if (ia_valid & ATTR_SIZE) {
904 if (attr->ia_size > ll_file_maxbytes(inode)) {
905 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
906 attr->ia_size, ll_file_maxbytes(inode));
910 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
913 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
914 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
915 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
919 /* We mark all of the fields "set" so MDS/OST does not re-set them */
920 if (attr->ia_valid & ATTR_CTIME) {
921 attr->ia_ctime = CURRENT_TIME;
922 attr->ia_valid |= ATTR_CTIME_SET;
924 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
925 attr->ia_atime = CURRENT_TIME;
926 attr->ia_valid |= ATTR_ATIME_SET;
928 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
929 attr->ia_mtime = CURRENT_TIME;
930 attr->ia_valid |= ATTR_MTIME_SET;
933 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
934 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
935 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
936 LTIME_S(CURRENT_TIME));
938 attr->ia_valid &= ~ATTR_SIZE;
940 /* If only OST attributes being set on objects, don't do MDS RPC.
941 * In that case, we need to check permissions and update the local
942 * inode ourselves so we can call obdo_from_inode() always. */
943 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
945 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
947 rc = md_setattr(sbi->ll_mdc_exp, &op_data,
948 attr, NULL, 0, NULL, 0, &request);
950 ptlrpc_req_finished(request);
951 if (rc != -EPERM && rc != -EACCES)
952 CERROR("md_setattr fails: rc = %d\n", rc);
956 rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0,
957 sbi->ll_osc_exp, &md);
959 ptlrpc_req_finished(request);
963 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
964 * but needed to set timestamps backwards on utime. */
965 inode_setattr(inode, attr);
966 ll_update_inode(inode, &md);
967 ptlrpc_req_finished(request);
969 if (!lsm || !S_ISREG(inode->i_mode)) {
970 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
974 /* The OST doesn't check permissions, but the alternative is
975 * a gratuitous RPC to the MDS. We already rely on the client
976 * to do read/write/truncate permission checks, so is mtime OK?
978 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
979 /* from sys_utime() */
980 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
981 if (current->fsuid != inode->i_uid &&
982 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
985 /* from inode_change_ok() */
986 if (current->fsuid != inode->i_uid &&
987 !capable(CAP_FOWNER))
992 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
993 inode_setattr(inode, attr);
996 /* We really need to get our PW lock before we change inode->i_size.
997 * If we don't we can race with other i_size updaters on our node, like
998 * ll_file_read. We can also race with i_size propogation to other
999 * nodes through dirtying and writeback of final cached pages. This
1000 * last one is especially bad for racing o_append users on other
1002 if (ia_valid & ATTR_SIZE) {
1003 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1005 struct lustre_handle lockh = { 0 };
1006 int err, ast_flags = 0;
1007 /* XXX when we fix the AST intents to pass the discard-range
1008 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1010 if (attr->ia_size == 0)
1011 ast_flags = LDLM_AST_DISCARD_DATA;
1013 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1014 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1016 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1018 down(&inode->i_sem);
1022 rc = vmtruncate(inode, attr->ia_size);
1024 /* We need to drop the semaphore here, because this unlock may
1025 * result in a cancellation, which will need the i_sem */
1027 /* unlock now as we don't mind others file lockers racing with
1028 * the mds updates below? */
1029 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1030 down(&inode->i_sem);
1032 CERROR("ll_extent_unlock failed: %d\n", err);
1036 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1039 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1040 inode->i_ino, LTIME_S(attr->ia_mtime));
1041 oa.o_id = lsm->lsm_object_id;
1042 oa.o_gr = lsm->lsm_object_gr;
1043 oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1044 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1045 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1046 rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL);
1048 CERROR("obd_setattr fails: rc=%d\n", rc);
1053 int ll_setattr(struct dentry *de, struct iattr *attr)
1055 LBUG(); /* code is unused, but leave this in case of VFS changes */
1059 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1060 unsigned long max_age)
1062 struct ll_sb_info *sbi = ll_s2sbi(sb);
1063 struct obd_statfs obd_osfs;
1067 rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age);
1069 CERROR("mdc_statfs fails: rc = %d\n", rc);
1073 osfs->os_type = sb->s_magic;
1075 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1076 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1078 rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age);
1080 CERROR("obd_statfs fails: rc = %d\n", rc);
1084 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1085 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1088 osfs->os_blocks = obd_osfs.os_blocks;
1089 osfs->os_bfree = obd_osfs.os_bfree;
1090 osfs->os_bavail = obd_osfs.os_bavail;
1092 /* If we don't have as many objects free on the OST as inodes
1093 * on the MDS, we reduce the total number of inodes to
1094 * compensate, so that the "inodes in use" number is correct.
1096 if (obd_osfs.os_ffree < osfs->os_ffree) {
1097 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1099 osfs->os_ffree = obd_osfs.os_ffree;
1105 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1107 struct obd_statfs osfs;
1110 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1111 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1113 /* For now we will always get up-to-date statfs values, but in the
1114 * future we may allow some amount of caching on the client (e.g.
1115 * from QOS or lprocfs updates). */
1116 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1120 statfs_unpack(sfs, &osfs);
1122 if (sizeof(sfs->f_blocks) == 4) {
1123 while (osfs.os_blocks > ~0UL) {
1126 osfs.os_blocks >>= 1;
1127 osfs.os_bfree >>= 1;
1128 osfs.os_bavail >>= 1;
1132 sfs->f_blocks = osfs.os_blocks;
1133 sfs->f_bfree = osfs.os_bfree;
1134 sfs->f_bavail = osfs.os_bavail;
1139 void dump_lsm(int level, struct lov_stripe_md *lsm)
1141 CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
1142 "stripe_size %u, stripe_count %u\n",
1143 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
1144 lsm->lsm_stripe_size, lsm->lsm_stripe_count);
1147 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1149 struct ll_inode_info *lli = ll_i2info(inode);
1150 struct mds_body *body = md->body;
1151 struct lov_stripe_md *lsm = md->lsm;
1152 struct mea *mea = md->mea;
1155 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1156 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1158 LASSERT(lsm->lsm_object_gr > 0);
1159 if (lli->lli_smd == NULL) {
1161 lli->lli_maxbytes = lsm->lsm_maxbytes;
1162 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1163 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1166 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1167 CERROR("lsm mismatch for inode %ld\n",
1169 CERROR("lli_smd:\n");
1170 dump_lsm(D_ERROR, lli->lli_smd);
1172 dump_lsm(D_ERROR, lsm);
1175 /* XXX FIXME -- We should decide on a safer (atomic) and
1176 * more elegant way to update the lsm */
1177 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1178 lli->lli_smd->lsm_oinfo[i].loi_id =
1179 lsm->lsm_oinfo[i].loi_id;
1180 lli->lli_smd->lsm_oinfo[i].loi_gr =
1181 lsm->lsm_oinfo[i].loi_gr;
1182 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1183 lsm->lsm_oinfo[i].loi_ost_idx;
1184 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1185 lsm->lsm_oinfo[i].loi_ost_gen;
1188 /* bug 2844 - limit i_blksize for broken user-space apps */
1189 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1190 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1191 if (lli->lli_smd != lsm)
1192 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1196 if (lli->lli_mea == NULL) {
1199 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1200 CERROR("mea mismatch for inode %lu\n",
1205 if (lli->lli_mea != mea)
1206 obd_free_memmd(ll_i2mdcexp(inode),
1207 (struct lov_stripe_md **) &mea);
1211 if (body->valid & OBD_MD_FLID)
1212 inode->i_ino = body->ino;
1213 if (body->valid & OBD_MD_FLATIME)
1214 LTIME_S(inode->i_atime) = body->atime;
1215 if (body->valid & OBD_MD_FLMTIME &&
1216 body->mtime > LTIME_S(inode->i_mtime)) {
1217 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1218 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1219 LTIME_S(inode->i_mtime) = body->mtime;
1221 if (body->valid & OBD_MD_FLCTIME &&
1222 body->ctime > LTIME_S(inode->i_ctime))
1223 LTIME_S(inode->i_ctime) = body->ctime;
1224 if (body->valid & OBD_MD_FLMODE)
1225 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
1226 if (body->valid & OBD_MD_FLTYPE)
1227 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
1228 if (body->valid & OBD_MD_FLUID)
1229 inode->i_uid = body->uid;
1230 if (body->valid & OBD_MD_FLGID)
1231 inode->i_gid = body->gid;
1232 if (body->valid & OBD_MD_FLFLAGS)
1233 inode->i_flags = body->flags;
1234 if (body->valid & OBD_MD_FLNLINK)
1235 inode->i_nlink = body->nlink;
1236 if (body->valid & OBD_MD_FLGENER)
1237 inode->i_generation = body->generation;
1238 if (body->valid & OBD_MD_FLRDEV)
1239 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1240 inode->i_rdev = body->rdev;
1242 inode->i_rdev = old_decode_dev(body->rdev);
1244 if (body->valid & OBD_MD_FLSIZE)
1245 inode->i_size = body->size;
1246 if (body->valid & OBD_MD_FLBLOCKS)
1247 inode->i_blocks = body->blocks;
1249 if (body->valid & OBD_MD_FLSIZE)
1250 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1252 lli->lli_mds = body->mds;
1253 inode->i_dev = (kdev_t) body->mds;
1254 LASSERT(body->mds < 1000);
1257 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1258 static struct backing_dev_info ll_backing_dev_info = {
1259 .ra_pages = 0, /* No readahead */
1260 .memory_backed = 0, /* Does contribute to dirty memory */
1264 void ll_read_inode2(struct inode *inode, void *opaque)
1266 struct lustre_md *md = opaque;
1267 struct ll_inode_info *lli = ll_i2info(inode);
1270 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1271 inode->i_generation, inode);
1275 LASSERT(!lli->lli_smd);
1277 /* Core attributes from the MDS first. This is a new inode, and
1278 * the VFS doesn't zero times in the core inode so we have to do
1279 * it ourselves. They will be overwritten by either MDS or OST
1280 * attributes - we just need to make sure they aren't newer. */
1281 LTIME_S(inode->i_mtime) = 0;
1282 LTIME_S(inode->i_atime) = 0;
1283 LTIME_S(inode->i_ctime) = 0;
1286 ll_update_inode(inode, md);
1288 /* OIDEBUG(inode); */
1290 if (S_ISREG(inode->i_mode)) {
1291 inode->i_op = &ll_file_inode_operations;
1292 inode->i_fop = &ll_file_operations;
1293 inode->i_mapping->a_ops = &ll_aops;
1295 } else if (S_ISDIR(inode->i_mode)) {
1296 inode->i_op = &ll_dir_inode_operations;
1297 inode->i_fop = &ll_dir_operations;
1298 inode->i_mapping->a_ops = &ll_dir_aops;
1300 } else if (S_ISLNK(inode->i_mode)) {
1301 inode->i_op = &ll_fast_symlink_inode_operations;
1304 inode->i_op = &ll_special_inode_operations;
1306 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1307 init_special_inode(inode, inode->i_mode,
1308 kdev_t_to_nr(inode->i_rdev));
1310 /* initializing backing dev info. */
1311 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1313 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1315 lli->ll_save_ifop = inode->i_fop;
1317 if (S_ISCHR(inode->i_mode))
1318 inode->i_fop = &ll_special_chr_inode_fops;
1319 else if (S_ISBLK(inode->i_mode))
1320 inode->i_fop = &ll_special_blk_inode_fops;
1321 else if (S_ISFIFO(inode->i_mode))
1322 inode->i_fop = &ll_special_fifo_inode_fops;
1323 else if (S_ISSOCK(inode->i_mode))
1324 inode->i_fop = &ll_special_sock_inode_fops;
1326 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1329 if (lli->ll_save_ifop->owner) {
1330 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1331 lli->ll_save_ifop->owner);
1337 int ll_iocontrol(struct inode *inode, struct file *file,
1338 unsigned int cmd, unsigned long arg)
1340 struct ll_sb_info *sbi = ll_i2sbi(inode);
1341 struct ptlrpc_request *req = NULL;
1346 case EXT3_IOC_GETFLAGS: {
1348 unsigned long valid = OBD_MD_FLFLAGS;
1349 struct mds_body *body;
1351 ll_inode2fid(&fid, inode);
1352 rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, 0, &req);
1354 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1358 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1360 if (body->flags & S_APPEND)
1361 flags |= EXT3_APPEND_FL;
1362 if (body->flags & S_IMMUTABLE)
1363 flags |= EXT3_IMMUTABLE_FL;
1364 if (body->flags & S_NOATIME)
1365 flags |= EXT3_NOATIME_FL;
1367 ptlrpc_req_finished (req);
1369 RETURN(put_user(flags, (int *)arg));
1371 case EXT3_IOC_SETFLAGS: {
1372 struct mdc_op_data op_data;
1375 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1377 if (get_user(flags, (int *)arg))
1384 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1386 memset(&attr, 0x0, sizeof(attr));
1387 attr.ia_attr_flags = flags;
1388 attr.ia_valid |= ATTR_ATTR_FLAG;
1390 rc = md_setattr(sbi->ll_mdc_exp, &op_data,
1391 &attr, NULL, 0, NULL, 0, &req);
1393 ptlrpc_req_finished(req);
1394 if (rc != -EPERM && rc != -EACCES)
1395 CERROR("md_setattr fails: rc = %d\n", rc);
1399 ptlrpc_req_finished(req);
1401 oa->o_id = lsm->lsm_object_id;
1402 oa->o_gr = lsm->lsm_object_gr;
1403 oa->o_flags = flags;
1404 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1406 rc = obd_setattr(sbi->ll_osc_exp, oa, lsm, NULL);
1409 if (rc != -EPERM && rc != -EACCES)
1410 CERROR("md_setattr fails: rc = %d\n", rc);
1414 if (flags & EXT3_APPEND_FL)
1415 inode->i_flags |= S_APPEND;
1417 inode->i_flags &= ~S_APPEND;
1418 if (flags & EXT3_IMMUTABLE_FL)
1419 inode->i_flags |= S_IMMUTABLE;
1421 inode->i_flags &= ~S_IMMUTABLE;
1422 if (flags & EXT3_NOATIME_FL)
1423 inode->i_flags |= S_NOATIME;
1425 inode->i_flags &= ~S_NOATIME;
1436 void ll_umount_begin(struct super_block *sb)
1438 struct ll_sb_info *sbi = ll_s2sbi(sb);
1439 struct obd_device *obd;
1440 struct obd_ioctl_data ioc_data = { 0 };
1442 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1444 obd = class_exp2obd(sbi->ll_mdc_exp);
1446 CERROR("Invalid MDC connection handle "LPX64"\n",
1447 sbi->ll_mdc_exp->exp_handle.h_cookie);
1451 obd->obd_no_recov = 1;
1452 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data,
1455 obd = class_exp2obd(sbi->ll_osc_exp);
1457 CERROR("Invalid LOV connection handle "LPX64"\n",
1458 sbi->ll_osc_exp->exp_handle.h_cookie);
1463 obd->obd_no_recov = 1;
1464 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data,
1467 /* Really, we'd like to wait until there are no requests outstanding,
1468 * and then continue. For now, we just invalidate the requests,
1469 * schedule, and hope.
1476 int ll_prep_inode(struct obd_export *osc_exp, struct obd_export *mdc_exp,
1477 struct inode **inode, struct ptlrpc_request *req,
1478 int offset, struct super_block *sb)
1480 struct lustre_md md;
1483 rc = mdc_req2lustre_md(mdc_exp, req, offset, osc_exp, &md);
1488 ll_update_inode(*inode, &md);
1491 *inode = ll_iget(sb, md.body->ino, &md);
1492 if (*inode == NULL || is_bad_inode(*inode)) {
1493 /* free the lsm if we allocated one above */
1495 obd_free_memmd(osc_exp, &md.lsm);
1497 obd_free_memmd(mdc_exp,
1498 (struct lov_stripe_md**)&md.mea);
1500 CERROR("new_inode -fatal: rc %d\n", rc);