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 <linux/lustre_snap.h>
36 #include "llite_internal.h"
38 kmem_cache_t *ll_file_data_slab;
40 extern struct address_space_operations ll_aops;
41 extern struct address_space_operations ll_dir_aops;
44 #define log2(n) ffz(~(n))
47 struct ll_sb_info *lustre_init_sbi(struct super_block *sb)
49 struct ll_sb_info *sbi = NULL;
53 OBD_ALLOC(sbi, sizeof(*sbi));
57 spin_lock_init(&sbi->ll_lock);
58 INIT_LIST_HEAD(&sbi->ll_pglist);
59 sbi->ll_pglist_gen = 0;
60 sbi->ll_max_read_ahead_pages = SBI_DEFAULT_RA_MAX;
61 INIT_LIST_HEAD(&sbi->ll_conn_chain);
62 INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
63 INIT_LIST_HEAD(&sbi->ll_mnt_list);
64 sema_init(&sbi->ll_gns_sem, 1);
65 init_completion(&sbi->ll_gns_completion);
66 sbi->ll_gns_state = LL_GNS_STATE_IDLE;
67 sbi->ll_gns_timer.data = (unsigned long)sbi;
68 sbi->ll_gns_timer.function = ll_gns_timer_callback;
69 init_timer(&sbi->ll_gns_timer);
70 INIT_LIST_HEAD(&sbi->ll_gns_sbi_head);
74 generate_random_uuid(uuid);
75 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
79 void lustre_free_sbi(struct super_block *sb)
81 struct ll_sb_info *sbi = ll_s2sbi(sb);
85 list_del(&sbi->ll_gns_sbi_head);
86 del_timer(&sbi->ll_gns_timer);
87 OBD_FREE(sbi, sizeof(*sbi));
93 int lustre_init_ea_size(struct ll_sb_info *sbi)
98 /* OSC may have larger ea size */
99 valsize = sizeof(desc);
100 rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc",
104 obd_init_ea_size(sbi->ll_mdc_exp, obd_size_diskmd(sbi->ll_osc_exp, NULL),
105 desc.ld_tgt_count*sizeof(struct llog_cookie));
110 int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
112 struct inode *root = 0;
113 struct ll_sb_info *sbi = ll_s2sbi(sb);
114 struct obd_device *obd;
115 struct ll_fid rootfid;
116 struct obd_statfs osfs;
117 struct ptlrpc_request *request = NULL;
118 struct lustre_handle osc_conn = {0, };
119 struct lustre_handle mdc_conn = {0, };
124 obd = class_name2obd(mdc);
126 CERROR("MDC %s: not setup or attached\n", mdc);
130 if (proc_lustre_fs_root) {
131 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
134 CERROR("could not register mount in /proc/lustre");
137 err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0);
139 CERROR("An MDS (mdc %s) is performing recovery, of which this"
140 " client is not a part. Please wait for recovery to "
141 "complete, abort, or time out.\n", mdc);
144 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
147 sbi->ll_mdc_exp = class_conn2export(&mdc_conn);
149 err = obd_statfs(obd, &osfs, jiffies - HZ);
153 LASSERT(osfs.os_bsize);
154 sb->s_blocksize = osfs.os_bsize;
155 sb->s_blocksize_bits = log2(osfs.os_bsize);
156 sb->s_magic = LL_SUPER_MAGIC;
157 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
159 devno = get_uuid2int(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid,
160 strlen(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid));
164 obd = class_name2obd(osc);
166 CERROR("OSC %s: not setup or attached\n", osc);
170 err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0);
172 CERROR("An OST (osc %s) is performing recovery, of which this"
173 " client is not a part. Please wait for recovery to "
174 "complete, abort, or time out.\n", osc);
177 CERROR("cannot connect to %s: rc = %d\n", osc, err);
180 sbi->ll_osc_exp = class_conn2export(&osc_conn);
182 lustre_init_ea_size(sbi);
184 err = md_getstatus(sbi->ll_mdc_exp, &rootfid);
186 CERROR("cannot mds_connect: rc = %d\n", err);
189 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
190 sbi->ll_rootino = rootfid.id;
192 sb->s_op = &lustre_super_operations;
195 * XXX: move this to after cbd setup? */
196 err = md_getattr(sbi->ll_mdc_exp, &rootfid,
197 OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS, 0, &request);
199 CERROR("md_getattr failed for root: rc = %d\n", err);
203 err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0,
204 sbi->ll_osc_exp, &md);
206 CERROR("failed to understand root inode md: rc = %d\n",err);
207 ptlrpc_req_finished (request);
211 LASSERT(sbi->ll_rootino != 0);
212 root = ll_iget(sb, sbi->ll_rootino, &md);
214 ptlrpc_req_finished(request);
216 if (root == NULL || is_bad_inode(root)) {
217 /* XXX might need iput() for bad inode */
218 CERROR("lustre_lite: bad iget4 for root\n");
219 GOTO(out_root, err = -EBADF);
222 err = ll_close_thread_start(&sbi->ll_lcq);
224 CERROR("cannot start close thread: rc %d\n", err);
228 ll_gns_add_timer(sbi);
230 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x,
231 backing dev info assigned to inode mapping is used for
232 determining maximal readahead. */
233 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
234 /* bug 2805 - set VM readahead to zero */
235 vm_max_readahead = vm_min_readahead = 0;
238 sb->s_root = d_alloc_root(root);
241 CWARN("Enabling PDIROPS\n");
242 sb->s_flags |= S_PDIROPS;
251 obd_disconnect(sbi->ll_osc_exp, 0);
253 obd_disconnect(sbi->ll_mdc_exp, 0);
255 lprocfs_unregister_mountpoint(sbi);
259 void lustre_common_put_super(struct super_block *sb)
261 struct ll_sb_info *sbi = ll_s2sbi(sb);
262 struct hlist_node *tmp, *next;
265 ll_gns_del_timer(sbi);
267 ll_close_thread_shutdown(sbi->ll_lcq);
269 list_del(&sbi->ll_conn_chain);
270 obd_disconnect(sbi->ll_osc_exp, 0);
272 lprocfs_unregister_mountpoint(sbi);
273 if (sbi->ll_proc_root) {
274 lprocfs_remove(sbi->ll_proc_root);
275 sbi->ll_proc_root = NULL;
278 obd_disconnect(sbi->ll_mdc_exp, 0);
280 // We do this to get rid of orphaned dentries. That is not really trw.
281 spin_lock(&dcache_lock);
282 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
283 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
284 CWARN("orphan dentry %*s (%p) at unmount\n",
285 dentry->d_name.len, dentry->d_name.name, dentry);
286 shrink_dcache_parent(dentry);
288 spin_unlock(&dcache_lock);
293 char *ll_read_opt(const char *opt, char *data)
299 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
300 if (strncmp(opt, data, strlen(opt)))
302 if ((value = strchr(data, '=')) == NULL)
306 OBD_ALLOC(retval, strlen(value) + 1);
308 CERROR("out of memory!\n");
312 memcpy(retval, value, strlen(value)+1);
313 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
317 int ll_set_opt(const char *opt, char *data, int fl)
321 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
322 if (strncmp(opt, data, strlen(opt)))
328 void ll_options(char *options, char **ost, char **mdc, int *flags,
332 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
333 char *opt_ptr = options;
342 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
343 for (this_char = strtok (options, ",");
345 this_char = strtok (NULL, ",")) {
347 while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
349 CDEBUG(D_SUPER, "this_char %s\n", this_char);
350 if (!*ost && (*ost = ll_read_opt("osc", this_char)))
352 if (!*mdc && (*mdc = ll_read_opt("mdc", this_char)))
354 if (!*clone_opts && (*clone_opts = ll_read_opt("clone",
357 if (!(*flags & LL_SBI_NOLCK) &&
358 ((*flags) = (*flags) |
359 ll_set_opt("nolock", this_char,
367 void ll_lli_init(struct ll_inode_info *lli)
369 sema_init(&lli->lli_open_sem, 1);
371 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
372 spin_lock_init(&lli->lli_lock);
373 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
374 lli->lli_inode_magic = LLI_INODE_MAGIC;
377 int ll_fill_super(struct super_block *sb, void *data, int silent)
379 struct ll_sb_info *sbi;
382 char *clone_opts = NULL;
386 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
388 sbi = lustre_init_sbi(sb);
392 sbi->ll_flags |= LL_SBI_READAHEAD;
393 ll_options(data, &osc, &mdc, &sbi->ll_flags, &clone_opts);
397 GOTO(out, err = -EINVAL);
402 GOTO(out, err = -EINVAL);
405 err = lustre_common_fill_super(sb, mdc, osc);
411 OBD_FREE(mdc, strlen(mdc) + 1);
413 OBD_FREE(osc, strlen(osc) + 1);
415 OBD_FREE(clone_opts, strlen(clone_opts) + 1);
418 } /* ll_read_super */
420 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
421 struct config_llog_instance *cfg, int allow_recov)
423 struct lustre_cfg lcfg;
424 struct portals_cfg pcfg;
425 char * peer = "MDS_PEER_UUID";
426 struct obd_device *obd;
427 struct lustre_handle mdc_conn = {0, };
428 struct obd_export *exp;
429 char * name = "mdc_dev";
431 struct obd_uuid mdc_uuid;
432 struct llog_ctxt *ctxt;
437 if (lmd_bad_magic(lmd))
440 generate_random_uuid(uuid);
441 class_uuid_unparse(uuid, &mdc_uuid);
443 if (lmd->lmd_local_nid) {
444 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
445 pcfg.pcfg_nal = lmd->lmd_nal;
446 pcfg.pcfg_nid = lmd->lmd_local_nid;
447 err = libcfs_nal_cmd(&pcfg);
452 if (lmd->lmd_nal == SOCKNAL) {
453 PCFG_INIT(pcfg, NAL_CMD_ADD_AUTOCONN);
454 pcfg.pcfg_nal = lmd->lmd_nal;
455 pcfg.pcfg_nid = lmd->lmd_server_nid;
456 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
457 pcfg.pcfg_misc = lmd->lmd_port;
458 pcfg.pcfg_size = 8388608;
459 pcfg.pcfg_flags = 0x4; /*share*/
460 err = libcfs_nal_cmd(&pcfg);
465 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
466 lcfg.lcfg_nid = lmd->lmd_server_nid;
467 lcfg.lcfg_inllen1 = strlen(peer) + 1;
468 lcfg.lcfg_inlbuf1 = peer;
469 lcfg.lcfg_nal = lmd->lmd_nal;
470 err = class_process_config(&lcfg);
472 GOTO(out_del_conn, err);
474 LCFG_INIT(lcfg, LCFG_ATTACH, name);
475 lcfg.lcfg_inlbuf1 = "mdc";
476 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
477 lcfg.lcfg_inlbuf2 = mdc_uuid.uuid;
478 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
479 err = class_process_config(&lcfg);
481 GOTO(out_del_uuid, err);
483 LCFG_INIT(lcfg, LCFG_SETUP, name);
484 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
485 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
486 lcfg.lcfg_inlbuf2 = peer;
487 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
488 err = class_process_config(&lcfg);
490 GOTO(out_detach, err);
492 obd = class_name2obd(name);
494 GOTO(out_cleanup, err = -EINVAL);
496 /* Disable initial recovery on this import */
497 err = obd_set_info(obd->obd_self_export,
498 strlen("initial_recov"), "initial_recov",
499 sizeof(allow_recov), &allow_recov);
501 GOTO(out_cleanup, err);
503 err = obd_connect(&mdc_conn, obd, &mdc_uuid, 0);
505 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
506 GOTO(out_cleanup, err);
509 exp = class_conn2export(&mdc_conn);
511 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
512 rc = class_config_process_llog(ctxt, profile, cfg);
514 CERROR("class_config_process_llog failed: rc = %d\n", rc);
516 err = obd_disconnect(exp, 0);
519 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
520 err = class_process_config(&lcfg);
525 LCFG_INIT(lcfg, LCFG_DETACH, name);
526 err = class_process_config(&lcfg);
531 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
532 lcfg.lcfg_inllen1 = strlen(peer) + 1;
533 lcfg.lcfg_inlbuf1 = peer;
534 err = class_process_config(&lcfg);
537 if (lmd->lmd_nal == SOCKNAL) {
538 PCFG_INIT(pcfg, NAL_CMD_DEL_AUTOCONN);
539 pcfg.pcfg_nal = lmd->lmd_nal;
540 pcfg.pcfg_nid = lmd->lmd_server_nid;
541 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
542 pcfg.pcfg_flags = 1; /*share*/
543 err = libcfs_nal_cmd(&pcfg);
554 int lustre_fill_super(struct super_block *sb, void *data, int silent)
556 struct lustre_mount_data * lmd = data;
557 struct ll_sb_info *sbi;
563 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
564 if (lmd_bad_magic(lmd))
567 sbi = lustre_init_sbi(sb);
571 sbi->ll_flags |= LL_SBI_READAHEAD;
573 if (lmd->lmd_profile) {
574 struct lustre_profile *lprof;
575 struct config_llog_instance cfg;
578 if (lmd->lmd_mds[0] == '\0') {
579 CERROR("no mds name\n");
580 GOTO(out_free, err = -EINVAL);
583 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
584 if (sbi->ll_lmd == NULL)
585 GOTO(out_free, err = -ENOMEM);
586 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
588 /* generate a string unique to this super, let's try
589 the address of the super itself.*/
590 len = (sizeof(sb) * 2) + 1;
591 OBD_ALLOC(sbi->ll_instance, len);
592 if (sbi->ll_instance == NULL)
593 GOTO(out_free, err = -ENOMEM);
594 sprintf(sbi->ll_instance, "%p", sb);
596 cfg.cfg_instance = sbi->ll_instance;
597 cfg.cfg_uuid = sbi->ll_sb_uuid;
598 cfg.cfg_local_nid = lmd->lmd_local_nid;
599 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
601 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
605 lprof = class_get_profile(lmd->lmd_profile);
607 CERROR("No profile found: %s\n", lmd->lmd_profile);
608 GOTO(out_free, err = -EINVAL);
611 OBD_FREE(osc, strlen(osc) + 1);
612 OBD_ALLOC(osc, strlen(lprof->lp_osc) +
613 strlen(sbi->ll_instance) + 2);
614 sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance);
617 OBD_FREE(mdc, strlen(mdc) + 1);
618 OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
619 strlen(sbi->ll_instance) + 2);
620 sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance);
625 GOTO(out_free, err = -EINVAL);
630 GOTO(out_free, err = -EINVAL);
633 err = lustre_common_fill_super(sb, mdc, osc);
640 OBD_FREE(mdc, strlen(mdc) + 1);
642 OBD_FREE(osc, strlen(osc) + 1);
648 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
651 if (sbi->ll_instance != NULL) {
652 struct lustre_mount_data *lmd = sbi->ll_lmd;
654 struct config_llog_instance cfg;
656 cfg.cfg_instance = sbi->ll_instance;
657 cfg.cfg_uuid = sbi->ll_sb_uuid;
659 OBD_ALLOC(cln_prof, len);
660 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
662 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
664 CERROR("Unable to process log: %s\n", cln_prof);
665 OBD_FREE(cln_prof, len);
666 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
668 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
673 } /* lustre_fill_super */
675 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
677 struct lustre_cfg lcfg;
678 struct obd_device *obd;
681 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
685 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
686 err = class_process_config(&lcfg);
688 CERROR("cleanup failed: %s\n", obd->obd_name);
692 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
693 err = class_process_config(&lcfg);
695 CERROR("detach failed: %s\n", obd->obd_name);
700 if (sbi->ll_lmd != NULL)
701 class_del_profile(sbi->ll_lmd->lmd_profile);
704 void lustre_put_super(struct super_block *sb)
706 struct obd_device *obd;
707 struct ll_sb_info *sbi = ll_s2sbi(sb);
708 int force_umount = 0;
711 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
712 obd = class_exp2obd(sbi->ll_mdc_exp);
714 force_umount = obd->obd_no_recov;
717 lustre_common_put_super(sb);
718 if (sbi->ll_lmd != NULL) {
720 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
722 struct config_llog_instance cfg;
725 CERROR("force umount, doing manual cleanup\n");
726 lustre_manual_cleanup(sbi);
730 cfg.cfg_instance = sbi->ll_instance;
731 cfg.cfg_uuid = sbi->ll_sb_uuid;
733 OBD_ALLOC(cln_prof, len);
734 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
736 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
738 CERROR("Unable to process log: %s, doing manual cleanup"
740 lustre_manual_cleanup(sbi);
743 OBD_FREE(cln_prof, len);
745 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
746 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
752 } /* lustre_put_super */
754 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
756 struct obd_export *mdc_exp = sbi->ll_mdc_exp;
757 struct lustre_mount_data *lmd = sbi->ll_lmd;
758 struct llog_ctxt *ctxt;
759 struct config_llog_instance cfg;
760 char *profile = lmd->lmd_profile, *name = NULL;
761 int rc, namelen = 0, version;
767 CERROR("Client not mounted with zero-conf; cannot process "
772 rc = ldlm_cli_cancel_unused(mdc_exp->exp_obd->obd_namespace, NULL,
773 LDLM_FL_CONFIG_CHANGE, NULL);
775 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
777 rc = obd_cancel_unused(sbi->ll_osc_exp, NULL, LDLM_FL_CONFIG_CHANGE,
780 CWARN("obd_cancel_unused(lov): %d\n", rc);
782 cfg.cfg_instance = sbi->ll_instance;
783 cfg.cfg_uuid = sbi->ll_sb_uuid;
784 cfg.cfg_local_nid = lmd->lmd_local_nid;
786 namelen = strlen(profile) + 20; /* -clean-######### */
787 OBD_ALLOC(name, namelen);
792 version = sbi->ll_config_version - 1;
793 sprintf(name, "%s-clean-%d", profile, version);
795 version = sbi->ll_config_version + 1;
796 sprintf(name, "%s-%d", profile, version);
799 CWARN("Applying configuration log %s\n", name);
801 ctxt = llog_get_context(&mdc_exp->exp_obd->obd_llogs,
802 LLOG_CONFIG_REPL_CTXT);
803 rc = class_config_process_llog(ctxt, name, &cfg);
805 sbi->ll_config_version = version;
806 CWARN("Finished applying configuration log %s: %d\n", name, rc);
808 if (rc == 0 && clean == 0) {
809 struct lov_desc desc;
811 valsize = sizeof(desc);
812 rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1,
813 "lovdesc", &valsize, &desc);
815 rc = obd_init_ea_size(mdc_exp,
816 obd_size_diskmd(sbi->ll_osc_exp, NULL),
818 sizeof(struct llog_cookie)));
820 OBD_FREE(name, namelen);
824 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
826 struct inode *inode = NULL;
827 l_lock(&lock->l_resource->lr_namespace->ns_lock);
828 if (lock->l_ast_data) {
829 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
830 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
831 inode = igrab(lock->l_ast_data);
833 CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
834 lock->l_ast_data, lli->lli_inode_magic);
837 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
841 int null_if_equal(struct ldlm_lock *lock, void *data)
843 if (data == lock->l_ast_data)
844 lock->l_ast_data = NULL;
846 if (lock->l_req_mode != lock->l_granted_mode)
847 return LDLM_ITER_STOP;
849 return LDLM_ITER_CONTINUE;
852 void ll_clear_inode(struct inode *inode)
855 struct ll_inode_info *lli = ll_i2info(inode);
856 struct ll_sb_info *sbi = ll_i2sbi(inode);
859 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
860 inode->i_generation, inode);
862 lli->lli_inode_magic = LLI_INODE_DEAD;
863 ll_inode2fid(&fid, inode);
864 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
865 md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
868 obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
869 null_if_equal, inode);
872 obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd);
877 /* FIXME: change cbdata for mea here */
878 obd_free_memmd(sbi->ll_mdc_exp,
879 (struct lov_stripe_md **) &lli->lli_mea);
883 if (lli->lli_symlink_name) {
884 OBD_FREE(lli->lli_symlink_name,
885 strlen(lli->lli_symlink_name) + 1);
886 lli->lli_symlink_name = NULL;
892 /* If this inode has objects allocated to it (lsm != NULL), then the OST
893 * object(s) determine the file size and mtime. Otherwise, the MDS will
894 * keep these values until such a time that objects are allocated for it.
895 * We do the MDS operations first, as it is checking permissions for us.
896 * We don't to the MDS RPC if there is nothing that we want to store there,
897 * otherwise there is no harm in updating mtime/atime on the MDS if we are
898 * going to do an RPC anyways.
900 * If we are doing a truncate, we will send the mtime and ctime updates
901 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
902 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
905 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
907 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
908 struct ll_sb_info *sbi = ll_i2sbi(inode);
909 struct ptlrpc_request *request = NULL;
910 struct mdc_op_data op_data;
911 int ia_valid = attr->ia_valid;
915 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
916 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
918 if (ia_valid & ATTR_SIZE) {
919 if (attr->ia_size > ll_file_maxbytes(inode)) {
920 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
921 attr->ia_size, ll_file_maxbytes(inode));
925 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
928 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
929 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
930 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
934 /* We mark all of the fields "set" so MDS/OST does not re-set them */
935 if (attr->ia_valid & ATTR_CTIME) {
936 attr->ia_ctime = CURRENT_TIME;
937 attr->ia_valid |= ATTR_CTIME_SET;
939 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
940 attr->ia_atime = CURRENT_TIME;
941 attr->ia_valid |= ATTR_ATIME_SET;
943 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
944 attr->ia_mtime = CURRENT_TIME;
945 attr->ia_valid |= ATTR_MTIME_SET;
948 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
949 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
950 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
951 LTIME_S(CURRENT_TIME));
953 attr->ia_valid &= ~ATTR_SIZE;
955 /* If only OST attributes being set on objects, don't do MDS RPC.
956 * In that case, we need to check permissions and update the local
957 * inode ourselves so we can call obdo_from_inode() always. */
958 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
960 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
962 rc = md_setattr(sbi->ll_mdc_exp, &op_data,
963 attr, NULL, 0, NULL, 0, &request);
965 ptlrpc_req_finished(request);
966 if (rc != -EPERM && rc != -EACCES)
967 CERROR("md_setattr fails: rc = %d\n", rc);
971 rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0,
972 sbi->ll_osc_exp, &md);
974 ptlrpc_req_finished(request);
978 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
979 * but needed to set timestamps backwards on utime. */
980 inode_setattr(inode, attr);
981 ll_update_inode(inode, &md);
982 ptlrpc_req_finished(request);
984 if (!lsm || !S_ISREG(inode->i_mode)) {
985 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
989 /* The OST doesn't check permissions, but the alternative is
990 * a gratuitous RPC to the MDS. We already rely on the client
991 * to do read/write/truncate permission checks, so is mtime OK?
993 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
994 /* from sys_utime() */
995 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
996 if (current->fsuid != inode->i_uid &&
997 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1000 /* from inode_change_ok() */
1001 if (current->fsuid != inode->i_uid &&
1002 !capable(CAP_FOWNER))
1007 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1008 inode_setattr(inode, attr);
1011 /* We really need to get our PW lock before we change inode->i_size.
1012 * If we don't we can race with other i_size updaters on our node, like
1013 * ll_file_read. We can also race with i_size propogation to other
1014 * nodes through dirtying and writeback of final cached pages. This
1015 * last one is especially bad for racing o_append users on other
1017 if (ia_valid & ATTR_SIZE) {
1018 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1020 struct lustre_handle lockh = { 0 };
1021 int err, ast_flags = 0;
1022 /* XXX when we fix the AST intents to pass the discard-range
1023 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1025 if (attr->ia_size == 0)
1026 ast_flags = LDLM_AST_DISCARD_DATA;
1028 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1029 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1031 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1033 down(&inode->i_sem);
1037 rc = vmtruncate(inode, attr->ia_size);
1039 /* We need to drop the semaphore here, because this unlock may
1040 * result in a cancellation, which will need the i_sem */
1042 /* unlock now as we don't mind others file lockers racing with
1043 * the mds updates below? */
1044 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1045 down(&inode->i_sem);
1047 CERROR("ll_extent_unlock failed: %d\n", err);
1051 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1054 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1055 inode->i_ino, LTIME_S(attr->ia_mtime));
1056 oa.o_id = lsm->lsm_object_id;
1057 oa.o_gr = lsm->lsm_object_gr;
1058 oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1059 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1060 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1061 rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL);
1063 CERROR("obd_setattr fails: rc=%d\n", rc);
1068 int ll_setattr(struct dentry *de, struct iattr *attr)
1070 LBUG(); /* code is unused, but leave this in case of VFS changes */
1074 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1075 unsigned long max_age)
1077 struct ll_sb_info *sbi = ll_s2sbi(sb);
1078 struct obd_statfs obd_osfs;
1082 rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age);
1084 CERROR("mdc_statfs fails: rc = %d\n", rc);
1088 osfs->os_type = sb->s_magic;
1090 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1091 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1093 rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age);
1095 CERROR("obd_statfs fails: rc = %d\n", rc);
1099 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1100 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1103 osfs->os_blocks = obd_osfs.os_blocks;
1104 osfs->os_bfree = obd_osfs.os_bfree;
1105 osfs->os_bavail = obd_osfs.os_bavail;
1107 /* If we don't have as many objects free on the OST as inodes
1108 * on the MDS, we reduce the total number of inodes to
1109 * compensate, so that the "inodes in use" number is correct.
1111 if (obd_osfs.os_ffree < osfs->os_ffree) {
1112 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1114 osfs->os_ffree = obd_osfs.os_ffree;
1120 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1122 struct obd_statfs osfs;
1125 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1126 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1128 /* For now we will always get up-to-date statfs values, but in the
1129 * future we may allow some amount of caching on the client (e.g.
1130 * from QOS or lprocfs updates). */
1131 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1135 statfs_unpack(sfs, &osfs);
1137 if (sizeof(sfs->f_blocks) == 4) {
1138 while (osfs.os_blocks > ~0UL) {
1141 osfs.os_blocks >>= 1;
1142 osfs.os_bfree >>= 1;
1143 osfs.os_bavail >>= 1;
1147 sfs->f_blocks = osfs.os_blocks;
1148 sfs->f_bfree = osfs.os_bfree;
1149 sfs->f_bavail = osfs.os_bavail;
1154 void dump_lsm(int level, struct lov_stripe_md *lsm)
1156 CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
1157 "stripe_size %u, stripe_count %u\n",
1158 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
1159 lsm->lsm_stripe_size, lsm->lsm_stripe_count);
1162 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1164 struct ll_inode_info *lli = ll_i2info(inode);
1165 struct mds_body *body = md->body;
1166 struct lov_stripe_md *lsm = md->lsm;
1167 struct mea *mea = md->mea;
1170 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1171 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1173 LASSERT(lsm->lsm_object_gr > 0);
1174 if (lli->lli_smd == NULL) {
1176 lli->lli_maxbytes = lsm->lsm_maxbytes;
1177 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1178 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1181 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1182 CERROR("lsm mismatch for inode %ld\n",
1184 CERROR("lli_smd:\n");
1185 dump_lsm(D_ERROR, lli->lli_smd);
1187 dump_lsm(D_ERROR, lsm);
1190 /* XXX FIXME -- We should decide on a safer (atomic) and
1191 * more elegant way to update the lsm */
1192 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1193 lli->lli_smd->lsm_oinfo[i].loi_id =
1194 lsm->lsm_oinfo[i].loi_id;
1195 lli->lli_smd->lsm_oinfo[i].loi_gr =
1196 lsm->lsm_oinfo[i].loi_gr;
1197 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1198 lsm->lsm_oinfo[i].loi_ost_idx;
1199 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1200 lsm->lsm_oinfo[i].loi_ost_gen;
1203 /* bug 2844 - limit i_blksize for broken user-space apps */
1204 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1205 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1206 if (lli->lli_smd != lsm)
1207 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1211 if (lli->lli_mea == NULL) {
1214 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1215 CERROR("mea mismatch for inode %lu\n",
1220 if (lli->lli_mea != mea)
1221 obd_free_memmd(ll_i2mdcexp(inode),
1222 (struct lov_stripe_md **) &mea);
1226 if (body->valid & OBD_MD_FLID)
1227 inode->i_ino = body->ino;
1228 if (body->valid & OBD_MD_FLATIME)
1229 LTIME_S(inode->i_atime) = body->atime;
1230 if (body->valid & OBD_MD_FLMTIME &&
1231 body->mtime > LTIME_S(inode->i_mtime)) {
1232 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1233 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1234 LTIME_S(inode->i_mtime) = body->mtime;
1236 if (body->valid & OBD_MD_FLCTIME &&
1237 body->ctime > LTIME_S(inode->i_ctime))
1238 LTIME_S(inode->i_ctime) = body->ctime;
1239 if (body->valid & OBD_MD_FLMODE)
1240 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
1241 if (body->valid & OBD_MD_FLTYPE)
1242 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
1243 if (body->valid & OBD_MD_FLUID)
1244 inode->i_uid = body->uid;
1245 if (body->valid & OBD_MD_FLGID)
1246 inode->i_gid = body->gid;
1247 if (body->valid & OBD_MD_FLFLAGS)
1248 inode->i_flags = body->flags;
1249 if (body->valid & OBD_MD_FLNLINK)
1250 inode->i_nlink = body->nlink;
1251 if (body->valid & OBD_MD_FLGENER)
1252 inode->i_generation = body->generation;
1253 if (body->valid & OBD_MD_FLRDEV)
1254 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1255 inode->i_rdev = body->rdev;
1257 inode->i_rdev = old_decode_dev(body->rdev);
1259 if (body->valid & OBD_MD_FLSIZE)
1260 inode->i_size = body->size;
1261 if (body->valid & OBD_MD_FLBLOCKS)
1262 inode->i_blocks = body->blocks;
1264 if (body->valid & OBD_MD_FLSIZE)
1265 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1267 lli->lli_mds = body->mds;
1268 inode->i_dev = (kdev_t) body->mds;
1269 LASSERT(body->mds < 1000);
1272 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1273 static struct backing_dev_info ll_backing_dev_info = {
1274 .ra_pages = 0, /* No readahead */
1275 .memory_backed = 0, /* Does contribute to dirty memory */
1279 void ll_read_inode2(struct inode *inode, void *opaque)
1281 struct lustre_md *md = opaque;
1282 struct ll_inode_info *lli = ll_i2info(inode);
1285 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1286 inode->i_generation, inode);
1290 LASSERT(!lli->lli_smd);
1292 /* Core attributes from the MDS first. This is a new inode, and
1293 * the VFS doesn't zero times in the core inode so we have to do
1294 * it ourselves. They will be overwritten by either MDS or OST
1295 * attributes - we just need to make sure they aren't newer. */
1296 LTIME_S(inode->i_mtime) = 0;
1297 LTIME_S(inode->i_atime) = 0;
1298 LTIME_S(inode->i_ctime) = 0;
1301 ll_update_inode(inode, md);
1303 /* OIDEBUG(inode); */
1305 if (S_ISREG(inode->i_mode)) {
1306 inode->i_op = &ll_file_inode_operations;
1307 inode->i_fop = &ll_file_operations;
1308 inode->i_mapping->a_ops = &ll_aops;
1310 } else if (S_ISDIR(inode->i_mode)) {
1311 inode->i_op = &ll_dir_inode_operations;
1312 inode->i_fop = &ll_dir_operations;
1313 inode->i_mapping->a_ops = &ll_dir_aops;
1315 } else if (S_ISLNK(inode->i_mode)) {
1316 inode->i_op = &ll_fast_symlink_inode_operations;
1319 inode->i_op = &ll_special_inode_operations;
1321 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1322 init_special_inode(inode, inode->i_mode,
1323 kdev_t_to_nr(inode->i_rdev));
1325 /* initializing backing dev info. */
1326 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1328 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1330 lli->ll_save_ifop = inode->i_fop;
1332 if (S_ISCHR(inode->i_mode))
1333 inode->i_fop = &ll_special_chr_inode_fops;
1334 else if (S_ISBLK(inode->i_mode))
1335 inode->i_fop = &ll_special_blk_inode_fops;
1336 else if (S_ISFIFO(inode->i_mode))
1337 inode->i_fop = &ll_special_fifo_inode_fops;
1338 else if (S_ISSOCK(inode->i_mode))
1339 inode->i_fop = &ll_special_sock_inode_fops;
1341 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1344 if (lli->ll_save_ifop->owner) {
1345 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1346 lli->ll_save_ifop->owner);
1352 void ll_delete_inode(struct inode *inode)
1356 struct ll_sb_info *sbi = ll_i2sbi(inode);
1359 ll_inode2fid(&fid, inode);
1361 rc = md_delete_object(sbi->ll_mdc_exp, &fid);
1363 CERROR("md_delete_object() failed, error %d.\n",
1371 int ll_iocontrol(struct inode *inode, struct file *file,
1372 unsigned int cmd, unsigned long arg)
1374 struct ll_sb_info *sbi = ll_i2sbi(inode);
1375 struct ptlrpc_request *req = NULL;
1380 case EXT3_IOC_GETFLAGS: {
1382 unsigned long valid = OBD_MD_FLFLAGS;
1383 struct mds_body *body;
1385 ll_inode2fid(&fid, inode);
1386 rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, 0, &req);
1388 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1392 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1394 if (body->flags & S_APPEND)
1395 flags |= EXT3_APPEND_FL;
1396 if (body->flags & S_IMMUTABLE)
1397 flags |= EXT3_IMMUTABLE_FL;
1398 if (body->flags & S_NOATIME)
1399 flags |= EXT3_NOATIME_FL;
1401 ptlrpc_req_finished (req);
1403 RETURN(put_user(flags, (int *)arg));
1405 case EXT3_IOC_SETFLAGS: {
1406 struct mdc_op_data op_data;
1409 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1411 if (get_user(flags, (int *)arg))
1418 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1420 memset(&attr, 0x0, sizeof(attr));
1421 attr.ia_attr_flags = flags;
1422 attr.ia_valid |= ATTR_ATTR_FLAG;
1424 rc = md_setattr(sbi->ll_mdc_exp, &op_data,
1425 &attr, NULL, 0, NULL, 0, &req);
1427 ptlrpc_req_finished(req);
1428 if (rc != -EPERM && rc != -EACCES)
1429 CERROR("md_setattr fails: rc = %d\n", rc);
1433 ptlrpc_req_finished(req);
1435 oa->o_id = lsm->lsm_object_id;
1436 oa->o_gr = lsm->lsm_object_gr;
1437 oa->o_flags = flags;
1438 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1440 rc = obd_setattr(sbi->ll_osc_exp, oa, lsm, NULL);
1443 if (rc != -EPERM && rc != -EACCES)
1444 CERROR("md_setattr fails: rc = %d\n", rc);
1448 if (flags & EXT3_APPEND_FL)
1449 inode->i_flags |= S_APPEND;
1451 inode->i_flags &= ~S_APPEND;
1452 if (flags & EXT3_IMMUTABLE_FL)
1453 inode->i_flags |= S_IMMUTABLE;
1455 inode->i_flags &= ~S_IMMUTABLE;
1456 if (flags & EXT3_NOATIME_FL)
1457 inode->i_flags |= S_NOATIME;
1459 inode->i_flags &= ~S_NOATIME;
1470 void ll_umount_begin(struct super_block *sb)
1472 struct ll_sb_info *sbi = ll_s2sbi(sb);
1473 struct obd_device *obd;
1474 struct obd_ioctl_data ioc_data = { 0 };
1476 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1478 obd = class_exp2obd(sbi->ll_mdc_exp);
1480 CERROR("Invalid MDC connection handle "LPX64"\n",
1481 sbi->ll_mdc_exp->exp_handle.h_cookie);
1485 obd->obd_no_recov = 1;
1486 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data,
1489 obd = class_exp2obd(sbi->ll_osc_exp);
1491 CERROR("Invalid LOV connection handle "LPX64"\n",
1492 sbi->ll_osc_exp->exp_handle.h_cookie);
1497 obd->obd_no_recov = 1;
1498 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data,
1501 /* Really, we'd like to wait until there are no requests outstanding,
1502 * and then continue. For now, we just invalidate the requests,
1503 * schedule, and hope.
1510 int ll_prep_inode(struct obd_export *osc_exp, struct obd_export *mdc_exp,
1511 struct inode **inode, struct ptlrpc_request *req,
1512 int offset, struct super_block *sb)
1514 struct lustre_md md;
1517 rc = mdc_req2lustre_md(mdc_exp, req, offset, osc_exp, &md);
1522 ll_update_inode(*inode, &md);
1525 *inode = ll_iget(sb, md.body->ino, &md);
1526 if (*inode == NULL || is_bad_inode(*inode)) {
1527 /* free the lsm if we allocated one above */
1529 obd_free_memmd(osc_exp, &md.lsm);
1531 obd_free_memmd(mdc_exp,
1532 (struct lov_stripe_md**)&md.mea);
1534 CERROR("new_inode -fatal: rc %d\n", rc);