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 if (num_physpages < SBI_DEFAULT_RA_MAX / 4)
60 sbi->ll_ra_info.ra_max_pages = num_physpages / 4;
62 sbi->ll_ra_info.ra_max_pages = SBI_DEFAULT_RA_MAX;
63 INIT_LIST_HEAD(&sbi->ll_conn_chain);
64 INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
65 INIT_LIST_HEAD(&sbi->ll_mnt_list);
66 sema_init(&sbi->ll_gns_sem, 1);
67 init_completion(&sbi->ll_gns_completion);
68 sbi->ll_gns_state = LL_GNS_STATE_IDLE;
69 sbi->ll_gns_timer.data = (unsigned long)sbi;
70 sbi->ll_gns_timer.function = ll_gns_timer_callback;
71 init_timer(&sbi->ll_gns_timer);
72 INIT_LIST_HEAD(&sbi->ll_gns_sbi_head);
76 generate_random_uuid(uuid);
77 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
81 void lustre_free_sbi(struct super_block *sb)
83 struct ll_sb_info *sbi = ll_s2sbi(sb);
87 list_del(&sbi->ll_gns_sbi_head);
88 del_timer(&sbi->ll_gns_timer);
89 OBD_FREE(sbi, sizeof(*sbi));
95 int lustre_init_dt_desc(struct ll_sb_info *sbi)
100 valsize = sizeof(sbi->ll_dt_desc);
101 memset(&sbi->ll_dt_desc, 0, sizeof(sbi->ll_dt_desc));
102 rc = obd_get_info(sbi->ll_dt_exp, strlen("lovdesc") + 1,
103 "lovdesc", &valsize, &sbi->ll_dt_desc);
107 int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
109 struct ll_sb_info *sbi = ll_s2sbi(sb);
110 struct ptlrpc_request *request = NULL;
111 struct lustre_handle dt_conn = {0, };
112 struct lustre_handle md_conn = {0, };
113 struct inode *root = NULL;
114 struct obd_device *obd;
115 struct obd_statfs osfs;
121 obd = class_name2obd(lmv);
123 CERROR("MDC %s: not setup or attached\n", lmv);
127 if (proc_lustre_fs_root) {
128 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
131 CERROR("could not register mount in /proc/lustre");
134 err = obd_connect(&md_conn, obd, &sbi->ll_sb_uuid, OBD_OPT_REAL_CLIENT);
136 CERROR("An MDS (mdc %s) is performing recovery, of which this"
137 " client is not a part. Please wait for recovery to "
138 "complete, abort, or time out.\n", lmv);
141 CERROR("cannot connect to %s: rc = %d\n", lmv, err);
144 sbi->ll_md_exp = class_conn2export(&md_conn);
145 err = obd_statfs(obd, &osfs, jiffies - HZ);
149 if (!osfs.os_bsize) {
150 CERROR("Invalid block size is detected.");
154 sb->s_magic = LL_SUPER_MAGIC;
155 sb->s_blocksize = osfs.os_bsize;
156 sb->s_blocksize_bits = log2(osfs.os_bsize);
157 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
159 devno = get_uuid2int(sbi->ll_md_exp->exp_obd->obd_uuid.uuid,
160 strlen(sbi->ll_md_exp->exp_obd->obd_uuid.uuid));
164 obd = class_name2obd(lov);
166 CERROR("OSC %s: not setup or attached\n", lov);
170 err = obd_connect(&dt_conn, obd, &sbi->ll_sb_uuid, OBD_OPT_REAL_CLIENT);
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", lov);
177 CERROR("cannot connect to %s: rc = %d\n", lov, err);
180 sbi->ll_dt_exp = class_conn2export(&dt_conn);
182 err = lustre_init_dt_desc(sbi);
184 int mdsize = obd_size_diskmd(sbi->ll_dt_exp, NULL);
185 obd_init_ea_size(sbi->ll_md_exp, mdsize,
186 sbi->ll_dt_desc.ld_tgt_count *
187 sizeof(struct llog_cookie));
190 err = md_getstatus(sbi->ll_md_exp, &sbi->ll_rootid);
192 CERROR("cannot mds_connect: rc = %d\n", err);
195 CDEBUG(D_SUPER, "rootid "DLID4"\n", OLID4(&sbi->ll_rootid));
197 sb->s_op = &lustre_super_operations;
200 * XXX: move this to after cbd setup? */
201 err = md_getattr(sbi->ll_md_exp, &sbi->ll_rootid,
202 OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS,
205 CERROR("md_getattr failed for root: rc = %d\n", err);
209 err = mdc_req2lustre_md(sbi->ll_md_exp, request, 0,
210 sbi->ll_dt_exp, &md);
212 CERROR("failed to understand root inode md: rc = %d\n", err);
213 ptlrpc_req_finished(request);
217 LASSERT(id_ino(&sbi->ll_rootid) != 0);
218 root = ll_iget(sb, id_ino(&sbi->ll_rootid), &md);
220 ptlrpc_req_finished(request);
222 if (root == NULL || is_bad_inode(root)) {
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, backing dev
236 info assigned to inode mapping is used for determining maximal
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);
246 CWARN("Enabling PDIROPS\n");
247 sb->s_flags |= S_PDIROPS;
255 obd_disconnect(sbi->ll_dt_exp, 0);
257 obd_disconnect(sbi->ll_md_exp, 0);
259 lprocfs_unregister_mountpoint(sbi);
263 void lustre_common_put_super(struct super_block *sb)
265 struct ll_sb_info *sbi = ll_s2sbi(sb);
266 struct hlist_node *tmp, *next;
269 ll_gns_del_timer(sbi);
270 ll_close_thread_shutdown(sbi->ll_lcq);
272 list_del(&sbi->ll_conn_chain);
273 obd_disconnect(sbi->ll_dt_exp, 0);
275 lprocfs_unregister_mountpoint(sbi);
276 if (sbi->ll_proc_root) {
277 lprocfs_remove(sbi->ll_proc_root);
278 sbi->ll_proc_root = NULL;
281 obd_disconnect(sbi->ll_md_exp, 0);
283 // We do this to get rid of orphaned dentries. That is not really trw.
284 spin_lock(&dcache_lock);
285 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
286 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
287 CWARN("orphan dentry %*s (%p) at unmount\n",
288 dentry->d_name.len, dentry->d_name.name, dentry);
289 shrink_dcache_parent(dentry);
291 spin_unlock(&dcache_lock);
295 char *ll_read_opt(const char *opt, char *data)
301 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
302 if (strncmp(opt, data, strlen(opt)))
304 if ((value = strchr(data, '=')) == NULL)
308 OBD_ALLOC(retval, strlen(value) + 1);
310 CERROR("out of memory!\n");
314 memcpy(retval, value, strlen(value)+1);
315 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
319 int ll_set_opt(const char *opt, char *data, int fl)
323 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
324 if (strncmp(opt, data, strlen(opt)))
330 void ll_options(char *options, char **lov, char **lmv, int *flags)
333 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
334 char *opt_ptr = options;
343 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
344 for (this_char = strtok (options, ",");
346 this_char = strtok (NULL, ",")) {
348 while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
350 CDEBUG(D_SUPER, "this_char %s\n", this_char);
351 if (!*lov && (*lov = ll_read_opt("osc", this_char)))
353 if (!*lmv && (*lmv = ll_read_opt("mdc", this_char)))
355 if (!(*flags & LL_SBI_NOLCK) &&
356 ((*flags) = (*flags) |
357 ll_set_opt("nolock", this_char,
365 void ll_lli_init(struct ll_inode_info *lli)
367 sema_init(&lli->lli_open_sem, 1);
369 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
370 spin_lock_init(&lli->lli_lock);
371 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
372 lli->lli_inode_magic = LLI_INODE_MAGIC;
373 memset(&lli->lli_id, 0, sizeof(lli->lli_id));
376 int ll_fill_super(struct super_block *sb, void *data, int silent)
378 struct ll_sb_info *sbi;
384 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
386 sbi = lustre_init_sbi(sb);
390 sbi->ll_flags |= LL_SBI_READAHEAD;
391 ll_options(data, &lov, &lmv, &sbi->ll_flags);
395 GOTO(out, err = -EINVAL);
400 GOTO(out, err = -EINVAL);
403 err = lustre_common_fill_super(sb, lmv, lov);
410 OBD_FREE(lmv, strlen(lmv) + 1);
412 OBD_FREE(lov, strlen(lov) + 1);
414 } /* ll_read_super */
416 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
417 struct config_llog_instance *cfg, int allow_recov)
419 struct lustre_cfg lcfg;
420 struct portals_cfg pcfg;
421 char *peer = "MDS_PEER_UUID";
422 struct obd_device *obd;
423 struct lustre_handle md_conn = {0, };
424 struct obd_export *exp;
425 char *name = "mdc_dev";
427 struct obd_uuid lmv_uuid;
428 struct llog_ctxt *ctxt;
433 if (lmd_bad_magic(lmd))
436 generate_random_uuid(uuid);
437 class_uuid_unparse(uuid, &lmv_uuid);
439 if (lmd->lmd_local_nid) {
440 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
441 pcfg.pcfg_nal = lmd->lmd_nal;
442 pcfg.pcfg_nid = lmd->lmd_local_nid;
443 err = libcfs_nal_cmd(&pcfg);
448 if (lmd->lmd_nal == SOCKNAL ||
449 lmd->lmd_nal == OPENIBNAL) {
450 PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);
451 pcfg.pcfg_nal = lmd->lmd_nal;
452 pcfg.pcfg_nid = lmd->lmd_server_nid;
453 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
454 pcfg.pcfg_misc = lmd->lmd_port;
455 pcfg.pcfg_size = 8388608;
456 pcfg.pcfg_flags = 0x4; /*share*/
457 err = libcfs_nal_cmd(&pcfg);
462 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
463 lcfg.lcfg_nid = lmd->lmd_server_nid;
464 lcfg.lcfg_inllen1 = strlen(peer) + 1;
465 lcfg.lcfg_inlbuf1 = peer;
466 lcfg.lcfg_nal = lmd->lmd_nal;
467 err = class_process_config(&lcfg);
469 GOTO(out_del_conn, err);
471 LCFG_INIT(lcfg, LCFG_ATTACH, name);
472 lcfg.lcfg_inlbuf1 = "mdc";
473 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
474 lcfg.lcfg_inlbuf2 = lmv_uuid.uuid;
475 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
476 err = class_process_config(&lcfg);
478 GOTO(out_del_uuid, err);
480 LCFG_INIT(lcfg, LCFG_SETUP, name);
481 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
482 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
483 lcfg.lcfg_inlbuf2 = peer;
484 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
485 err = class_process_config(&lcfg);
487 GOTO(out_detach, err);
489 obd = class_name2obd(name);
491 GOTO(out_cleanup, err = -EINVAL);
493 /* Disable initial recovery on this import */
494 err = obd_set_info(obd->obd_self_export,
495 strlen("initial_recov"), "initial_recov",
496 sizeof(allow_recov), &allow_recov);
498 GOTO(out_cleanup, err);
500 err = obd_connect(&md_conn, obd, &lmv_uuid, 0);
502 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
503 GOTO(out_cleanup, err);
506 exp = class_conn2export(&md_conn);
508 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
509 rc = class_config_process_llog(ctxt, profile, cfg);
511 CERROR("class_config_process_llog failed: rc = %d\n", rc);
513 err = obd_disconnect(exp, 0);
517 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
518 err = class_process_config(&lcfg);
523 LCFG_INIT(lcfg, LCFG_DETACH, name);
524 err = class_process_config(&lcfg);
529 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
530 lcfg.lcfg_inllen1 = strlen(peer) + 1;
531 lcfg.lcfg_inlbuf1 = peer;
532 err = class_process_config(&lcfg);
535 if (lmd->lmd_nal == SOCKNAL ||
536 lmd->lmd_nal == OPENIBNAL) {
537 PCFG_INIT(pcfg, NAL_CMD_DEL_PEER);
538 pcfg.pcfg_nal = lmd->lmd_nal;
539 pcfg.pcfg_nid = lmd->lmd_server_nid;
540 pcfg.pcfg_flags = 1; /* single_share */
541 err = libcfs_nal_cmd(&pcfg);
552 int lustre_fill_super(struct super_block *sb, void *data, int silent)
554 struct lustre_mount_data * lmd = data;
555 char *lov = NULL, *lmv = NULL;
556 struct ll_sb_info *sbi;
560 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
561 if (lmd_bad_magic(lmd))
564 sbi = lustre_init_sbi(sb);
568 sbi->ll_flags |= LL_SBI_READAHEAD;
570 if (lmd->lmd_profile) {
571 struct lustre_profile *lprof;
572 struct config_llog_instance cfg;
575 if (lmd->lmd_mds[0] == '\0') {
576 CERROR("no mds name\n");
577 GOTO(out_free, err = -EINVAL);
580 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
581 if (sbi->ll_lmd == NULL)
582 GOTO(out_free, err = -ENOMEM);
583 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
585 /* generate a string unique to this super, let's try
586 the address of the super itself.*/
587 len = (sizeof(sb) * 2) + 1;
588 OBD_ALLOC(sbi->ll_instance, len);
589 if (sbi->ll_instance == NULL)
590 GOTO(out_free, err = -ENOMEM);
591 sprintf(sbi->ll_instance, "%p", sb);
593 cfg.cfg_instance = sbi->ll_instance;
594 cfg.cfg_uuid = sbi->ll_sb_uuid;
595 cfg.cfg_local_nid = lmd->lmd_local_nid;
596 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
598 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
602 lprof = class_get_profile(lmd->lmd_profile);
604 CERROR("No profile found: %s\n", lmd->lmd_profile);
605 GOTO(out_free, err = -EINVAL);
608 OBD_FREE(lov, strlen(lov) + 1);
609 OBD_ALLOC(lov, strlen(lprof->lp_lov) +
610 strlen(sbi->ll_instance) + 2);
611 sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance);
614 OBD_FREE(lmv, strlen(lmv) + 1);
615 OBD_ALLOC(lmv, strlen(lprof->lp_lmv) +
616 strlen(sbi->ll_instance) + 2);
617 sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance);
622 GOTO(out_free, err = -EINVAL);
627 GOTO(out_free, err = -EINVAL);
630 err = lustre_common_fill_super(sb, lmv, lov);
637 OBD_FREE(lmv, strlen(lmv) + 1);
639 OBD_FREE(lov, strlen(lov) + 1);
645 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
648 if (sbi->ll_instance != NULL) {
649 struct lustre_mount_data *lmd = sbi->ll_lmd;
651 struct config_llog_instance cfg;
653 cfg.cfg_instance = sbi->ll_instance;
654 cfg.cfg_uuid = sbi->ll_sb_uuid;
656 OBD_ALLOC(cln_prof, len);
657 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
659 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
661 CERROR("Unable to process log: %s\n", cln_prof);
662 OBD_FREE(cln_prof, len);
663 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
665 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
670 } /* lustre_fill_super */
672 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
674 struct lustre_cfg lcfg;
675 struct obd_device *obd;
678 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
682 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
683 err = class_process_config(&lcfg);
685 CERROR("cleanup failed: %s\n", obd->obd_name);
689 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
690 err = class_process_config(&lcfg);
692 CERROR("detach failed: %s\n", obd->obd_name);
697 if (sbi->ll_lmd != NULL)
698 class_del_profile(sbi->ll_lmd->lmd_profile);
701 void lustre_put_super(struct super_block *sb)
703 struct obd_device *obd;
704 struct ll_sb_info *sbi = ll_s2sbi(sb);
705 int force_umount = 0;
708 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
709 obd = class_exp2obd(sbi->ll_md_exp);
711 force_umount = obd->obd_no_recov;
714 lustre_common_put_super(sb);
715 if (sbi->ll_lmd != NULL) {
717 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
719 struct config_llog_instance cfg;
722 CERROR("force umount, doing manual cleanup\n");
723 lustre_manual_cleanup(sbi);
727 cfg.cfg_instance = sbi->ll_instance;
728 cfg.cfg_uuid = sbi->ll_sb_uuid;
730 OBD_ALLOC(cln_prof, len);
731 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
733 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
735 CERROR("Unable to process log: %s, doing manual cleanup"
737 lustre_manual_cleanup(sbi);
740 OBD_FREE(cln_prof, len);
742 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
743 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
749 } /* lustre_put_super */
751 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
753 struct obd_export *md_exp = sbi->ll_md_exp;
754 struct lustre_mount_data *lmd = sbi->ll_lmd;
755 struct llog_ctxt *ctxt;
756 struct config_llog_instance cfg;
757 char *profile = lmd->lmd_profile, *name = NULL;
758 int rc, namelen = 0, version;
764 CERROR("Client not mounted with zero-conf; cannot process "
769 rc = ldlm_cli_cancel_unused(md_exp->exp_obd->obd_namespace, NULL,
770 LDLM_FL_CONFIG_CHANGE, NULL);
772 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
774 rc = obd_cancel_unused(sbi->ll_dt_exp, NULL, LDLM_FL_CONFIG_CHANGE,
777 CWARN("obd_cancel_unused(lov): %d\n", rc);
779 cfg.cfg_instance = sbi->ll_instance;
780 cfg.cfg_uuid = sbi->ll_sb_uuid;
781 cfg.cfg_local_nid = lmd->lmd_local_nid;
783 namelen = strlen(profile) + 20; /* -clean-######### */
784 OBD_ALLOC(name, namelen);
789 version = sbi->ll_config_version - 1;
790 sprintf(name, "%s-clean-%d", profile, version);
792 version = sbi->ll_config_version + 1;
793 sprintf(name, "%s-%d", profile, version);
796 CWARN("Applying configuration log %s\n", name);
798 ctxt = llog_get_context(&md_exp->exp_obd->obd_llogs,
799 LLOG_CONFIG_REPL_CTXT);
800 rc = class_config_process_llog(ctxt, name, &cfg);
802 sbi->ll_config_version = version;
803 CWARN("Finished applying configuration log %s: %d\n", name, rc);
805 if (rc == 0 && clean == 0) {
806 struct lov_desc desc;
808 valsize = sizeof(desc);
809 rc = obd_get_info(sbi->ll_dt_exp, strlen("lovdesc") + 1,
810 "lovdesc", &valsize, &desc);
812 rc = obd_init_ea_size(md_exp,
813 obd_size_diskmd(sbi->ll_dt_exp, NULL),
815 sizeof(struct llog_cookie)));
817 OBD_FREE(name, namelen);
821 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
823 struct inode *inode = NULL;
824 l_lock(&lock->l_resource->lr_namespace->ns_lock);
825 if (lock->l_ast_data) {
826 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
827 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
828 inode = igrab(lock->l_ast_data);
830 CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
831 lock->l_ast_data, lli->lli_inode_magic);
834 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
838 int null_if_equal(struct ldlm_lock *lock, void *data)
840 if (data == lock->l_ast_data) {
841 lock->l_ast_data = NULL;
843 if (lock->l_req_mode != lock->l_granted_mode)
844 LDLM_ERROR(lock,"clearing inode with ungranted lock\n");
847 return LDLM_ITER_CONTINUE;
850 void ll_clear_inode(struct inode *inode)
853 struct ll_inode_info *lli = ll_i2info(inode);
854 struct ll_sb_info *sbi = ll_i2sbi(inode);
857 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
858 inode->i_generation, inode);
860 lli->lli_inode_magic = LLI_INODE_DEAD;
861 ll_inode2id(&id, inode);
863 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
864 md_change_cbdata(sbi->ll_md_exp, &id, null_if_equal, inode);
867 obd_change_cbdata(sbi->ll_dt_exp, lli->lli_smd,
868 null_if_equal, inode);
871 obd_free_memmd(sbi->ll_dt_exp, &lli->lli_smd);
876 obd_free_memmd(sbi->ll_md_exp,
877 (struct lov_stripe_md **) &lli->lli_mea);
881 if (lli->lli_symlink_name) {
882 OBD_FREE(lli->lli_symlink_name,
883 strlen(lli->lli_symlink_name) + 1);
884 lli->lli_symlink_name = NULL;
890 /* If this inode has objects allocated to it (lsm != NULL), then the OST
891 * object(s) determine the file size and mtime. Otherwise, the MDS will
892 * keep these values until such a time that objects are allocated for it.
893 * We do the MDS operations first, as it is checking permissions for us.
894 * We don't to the MDS RPC if there is nothing that we want to store there,
895 * otherwise there is no harm in updating mtime/atime on the MDS if we are
896 * going to do an RPC anyways.
898 * If we are doing a truncate, we will send the mtime and ctime updates
899 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
900 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
903 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
905 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
906 struct ll_sb_info *sbi = ll_i2sbi(inode);
907 struct ptlrpc_request *request = NULL;
908 struct mdc_op_data *op_data;
909 int ia_valid = attr->ia_valid;
913 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
914 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
916 if (ia_valid & ATTR_SIZE) {
917 if (attr->ia_size > ll_file_maxbytes(inode)) {
918 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
919 attr->ia_size, ll_file_maxbytes(inode));
923 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
926 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
927 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
928 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
932 /* We mark all of the fields "set" so MDS/OST does not re-set them */
933 if (attr->ia_valid & ATTR_CTIME) {
934 attr->ia_ctime = CURRENT_TIME;
935 attr->ia_valid |= ATTR_CTIME_SET;
937 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
938 attr->ia_atime = CURRENT_TIME;
939 attr->ia_valid |= ATTR_ATIME_SET;
941 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
942 attr->ia_mtime = CURRENT_TIME;
943 attr->ia_valid |= ATTR_MTIME_SET;
946 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
947 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
948 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
949 LTIME_S(CURRENT_TIME));
951 attr->ia_valid &= ~ATTR_SIZE;
953 /* If only OST attributes being set on objects, don't do MDS RPC.
954 * In that case, we need to check permissions and update the local
955 * inode ourselves so we can call obdo_from_inode() always. */
956 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
959 OBD_ALLOC(op_data, sizeof(*op_data));
962 ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
964 rc = md_setattr(sbi->ll_md_exp, op_data,
965 attr, NULL, 0, NULL, 0, &request);
966 OBD_FREE(op_data, sizeof(*op_data));
968 ptlrpc_req_finished(request);
969 if (rc != -EPERM && rc != -EACCES)
970 CERROR("md_setattr fails: rc = %d\n", rc);
974 rc = mdc_req2lustre_md(sbi->ll_md_exp, request, 0,
975 sbi->ll_dt_exp, &md);
977 ptlrpc_req_finished(request);
981 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
982 * but needed to set timestamps backwards on utime. */
983 inode_setattr(inode, attr);
984 ll_update_inode(inode, &md);
985 ptlrpc_req_finished(request);
987 if (!lsm || !S_ISREG(inode->i_mode)) {
988 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
992 /* The OST doesn't check permissions, but the alternative is
993 * a gratuitous RPC to the MDS. We already rely on the client
994 * to do read/write/truncate permission checks, so is mtime OK?
996 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
997 /* from sys_utime() */
998 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
999 if (current->fsuid != inode->i_uid &&
1000 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1003 /* from inode_change_ok() */
1004 if (current->fsuid != inode->i_uid &&
1005 !capable(CAP_FOWNER))
1010 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1011 inode_setattr(inode, attr);
1014 /* We really need to get our PW lock before we change inode->i_size.
1015 * If we don't we can race with other i_size updaters on our node, like
1016 * ll_file_read. We can also race with i_size propogation to other
1017 * nodes through dirtying and writeback of final cached pages. This
1018 * last one is especially bad for racing o_append users on other
1020 if (ia_valid & ATTR_SIZE) {
1021 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1023 struct lustre_handle lockh = { 0 };
1024 int err, ast_flags = 0;
1025 /* XXX when we fix the AST intents to pass the discard-range
1026 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1028 if (attr->ia_size == 0)
1029 ast_flags = LDLM_AST_DISCARD_DATA;
1031 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1032 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1034 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1035 ast_flags, &ll_i2sbi(inode)->ll_seek_stime);
1036 down(&inode->i_sem);
1040 rc = vmtruncate(inode, attr->ia_size);
1042 /* We need to drop the semaphore here, because this unlock may
1043 * result in a cancellation, which will need the i_sem */
1045 /* unlock now as we don't mind others file lockers racing with
1046 * the mds updates below? */
1047 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1048 down(&inode->i_sem);
1050 CERROR("ll_extent_unlock failed: %d\n", err);
1054 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1055 struct obdo *oa = NULL;
1057 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1058 inode->i_ino, LTIME_S(attr->ia_mtime));
1064 oa->o_id = lsm->lsm_object_id;
1065 oa->o_gr = lsm->lsm_object_gr;
1066 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1067 obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1068 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1069 rc = obd_setattr(sbi->ll_dt_exp, oa, lsm, NULL);
1072 CERROR("obd_setattr fails: rc = %d\n", rc);
1077 int ll_setattr(struct dentry *de, struct iattr *attr)
1079 LBUG(); /* code is unused, but leave this in case of VFS changes */
1083 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1084 unsigned long max_age)
1086 struct ll_sb_info *sbi = ll_s2sbi(sb);
1087 struct obd_statfs obd_osfs;
1091 rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age);
1093 CERROR("mdc_statfs fails: rc = %d\n", rc);
1097 osfs->os_type = sb->s_magic;
1099 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1100 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1102 rc = obd_statfs(class_exp2obd(sbi->ll_dt_exp), &obd_osfs, max_age);
1104 CERROR("obd_statfs fails: rc = %d\n", rc);
1108 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1109 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1112 osfs->os_blocks = obd_osfs.os_blocks;
1113 osfs->os_bfree = obd_osfs.os_bfree;
1114 osfs->os_bavail = obd_osfs.os_bavail;
1116 /* If we don't have as many objects free on the OST as inodes
1117 * on the MDS, we reduce the total number of inodes to
1118 * compensate, so that the "inodes in use" number is correct.
1120 if (obd_osfs.os_ffree < osfs->os_ffree) {
1121 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1123 osfs->os_ffree = obd_osfs.os_ffree;
1129 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1131 struct obd_statfs osfs;
1134 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p\n", sb);
1135 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1137 /* For now we will always get up-to-date statfs values, but in the
1138 * future we may allow some amount of caching on the client (e.g.
1139 * from QOS or lprocfs updates). */
1140 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1144 statfs_unpack(sfs, &osfs);
1146 if (sizeof(sfs->f_blocks) == 4) {
1147 while (osfs.os_blocks > ~0UL) {
1150 osfs.os_blocks >>= 1;
1151 osfs.os_bfree >>= 1;
1152 osfs.os_bavail >>= 1;
1156 sfs->f_blocks = osfs.os_blocks;
1157 sfs->f_bfree = osfs.os_bfree;
1158 sfs->f_bavail = osfs.os_bavail;
1163 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1165 struct ll_inode_info *lli = ll_i2info(inode);
1166 struct lov_stripe_md *lsm = md->lsm;
1167 struct mds_body *body = md->body;
1168 struct mea *mea = md->mea;
1171 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1172 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1174 LASSERT(lsm->lsm_object_gr > 0);
1175 if (lli->lli_smd == NULL) {
1177 lli->lli_maxbytes = lsm->lsm_maxbytes;
1178 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1179 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1182 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1183 CERROR("lsm mismatch for inode %ld\n",
1185 CERROR("lli_smd:\n");
1186 dump_lsm(D_ERROR, lli->lli_smd);
1188 dump_lsm(D_ERROR, lsm);
1191 /* XXX FIXME -- We should decide on a safer (atomic) and
1192 * more elegant way to update the lsm */
1193 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1194 lli->lli_smd->lsm_oinfo[i].loi_id =
1195 lsm->lsm_oinfo[i].loi_id;
1196 lli->lli_smd->lsm_oinfo[i].loi_gr =
1197 lsm->lsm_oinfo[i].loi_gr;
1198 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1199 lsm->lsm_oinfo[i].loi_ost_idx;
1200 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1201 lsm->lsm_oinfo[i].loi_ost_gen;
1204 /* bug 2844 - limit i_blksize for broken user-space apps */
1205 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1206 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1207 if (lli->lli_smd != lsm)
1208 obd_free_memmd(ll_i2dtexp(inode), &lsm);
1212 if (lli->lli_mea == NULL) {
1215 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1216 CERROR("mea mismatch for inode %lu\n",
1221 if (lli->lli_mea != mea)
1222 obd_free_memmd(ll_i2mdexp(inode),
1223 (struct lov_stripe_md **) &mea);
1226 /* MDS is supposed to return correct fid always. */
1227 LASSERT(id_fid(&body->id1) != 0);
1228 id_assign_fid(&lli->lli_id, &body->id1);
1230 if ((body->valid & OBD_MD_FLID) || (body->valid & OBD_MD_FLGENER))
1231 id_assign_stc(&lli->lli_id, &body->id1);
1233 if (body->valid & OBD_MD_FLID)
1234 inode->i_ino = id_ino(&body->id1);
1235 if (body->valid & OBD_MD_FLGENER)
1236 inode->i_generation = id_gen(&body->id1);
1237 if (body->valid & OBD_MD_FLATIME)
1238 LTIME_S(inode->i_atime) = body->atime;
1239 if (body->valid & OBD_MD_FLMTIME &&
1240 body->mtime > LTIME_S(inode->i_mtime)) {
1241 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1242 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1243 LTIME_S(inode->i_mtime) = body->mtime;
1245 if (body->valid & OBD_MD_FLCTIME &&
1246 body->ctime > LTIME_S(inode->i_ctime))
1247 LTIME_S(inode->i_ctime) = body->ctime;
1248 if (body->valid & OBD_MD_FLMODE) {
1249 inode->i_mode = (inode->i_mode & S_IFMT) |
1250 (body->mode & ~S_IFMT);
1252 if (body->valid & OBD_MD_FLTYPE) {
1253 inode->i_mode = (inode->i_mode & ~S_IFMT) |
1254 (body->mode & S_IFMT);
1256 if (body->valid & OBD_MD_FLUID)
1257 inode->i_uid = body->uid;
1258 if (body->valid & OBD_MD_FLGID)
1259 inode->i_gid = body->gid;
1260 if (body->valid & OBD_MD_FLFLAGS)
1261 inode->i_flags = body->flags;
1262 if (body->valid & OBD_MD_FLNLINK)
1263 inode->i_nlink = body->nlink;
1264 if (body->valid & OBD_MD_FLRDEV)
1265 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1266 inode->i_rdev = body->rdev;
1268 inode->i_rdev = old_decode_dev(body->rdev);
1270 if (body->valid & OBD_MD_FLSIZE)
1271 inode->i_size = body->size;
1272 if (body->valid & OBD_MD_FLBLOCKS)
1273 inode->i_blocks = body->blocks;
1275 if (body->valid & OBD_MD_FLSIZE)
1276 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1278 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1279 inode->i_dev = (kdev_t)id_group(&lli->lli_id);
1283 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1284 static struct backing_dev_info ll_backing_dev_info = {
1285 .ra_pages = 0, /* No readahead */
1286 .memory_backed = 0, /* Does contribute to dirty memory */
1290 void ll_read_inode2(struct inode *inode, void *opaque)
1292 struct lustre_md *md = opaque;
1293 struct ll_inode_info *lli = ll_i2info(inode);
1296 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1297 inode->i_generation, inode);
1301 LASSERT(!lli->lli_smd);
1303 /* Core attributes from the MDS first. This is a new inode, and
1304 * the VFS doesn't zero times in the core inode so we have to do
1305 * it ourselves. They will be overwritten by either MDS or OST
1306 * attributes - we just need to make sure they aren't newer. */
1307 LTIME_S(inode->i_mtime) = 0;
1308 LTIME_S(inode->i_atime) = 0;
1309 LTIME_S(inode->i_ctime) = 0;
1312 ll_update_inode(inode, md);
1314 /* OIDEBUG(inode); */
1316 if (S_ISREG(inode->i_mode)) {
1317 inode->i_op = &ll_file_inode_operations;
1318 inode->i_fop = &ll_file_operations;
1319 inode->i_mapping->a_ops = &ll_aops;
1321 } else if (S_ISDIR(inode->i_mode)) {
1322 inode->i_op = &ll_dir_inode_operations;
1323 inode->i_fop = &ll_dir_operations;
1324 inode->i_mapping->a_ops = &ll_dir_aops;
1326 } else if (S_ISLNK(inode->i_mode)) {
1327 inode->i_op = &ll_fast_symlink_inode_operations;
1330 inode->i_op = &ll_special_inode_operations;
1332 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1333 init_special_inode(inode, inode->i_mode,
1334 kdev_t_to_nr(inode->i_rdev));
1336 /* initializing backing dev info. */
1337 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1339 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1341 lli->ll_save_ifop = inode->i_fop;
1343 if (S_ISCHR(inode->i_mode))
1344 inode->i_fop = &ll_special_chr_inode_fops;
1345 else if (S_ISBLK(inode->i_mode))
1346 inode->i_fop = &ll_special_blk_inode_fops;
1347 else if (S_ISFIFO(inode->i_mode))
1348 inode->i_fop = &ll_special_fifo_inode_fops;
1349 else if (S_ISSOCK(inode->i_mode))
1350 inode->i_fop = &ll_special_sock_inode_fops;
1352 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1355 if (lli->ll_save_ifop->owner) {
1356 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1357 lli->ll_save_ifop->owner);
1363 void ll_delete_inode(struct inode *inode)
1365 struct ll_sb_info *sbi = ll_i2sbi(inode);
1366 struct lustre_id id;
1370 ll_inode2id(&id, inode);
1372 rc = md_delete_inode(sbi->ll_md_exp, &id);
1374 CERROR("md_delete_inode() failed, error %d\n",
1382 int ll_iocontrol(struct inode *inode, struct file *file,
1383 unsigned int cmd, unsigned long arg)
1385 struct ll_sb_info *sbi = ll_i2sbi(inode);
1386 struct ptlrpc_request *req = NULL;
1391 case EXT3_IOC_GETFLAGS: {
1392 struct lustre_id id;
1393 __u64 valid = OBD_MD_FLFLAGS;
1394 struct mds_body *body;
1396 ll_inode2id(&id, inode);
1397 rc = md_getattr(sbi->ll_md_exp, &id, valid, 0, &req);
1399 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1403 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1405 if (body->flags & S_APPEND)
1406 flags |= EXT3_APPEND_FL;
1407 if (body->flags & S_IMMUTABLE)
1408 flags |= EXT3_IMMUTABLE_FL;
1409 if (body->flags & S_NOATIME)
1410 flags |= EXT3_NOATIME_FL;
1412 ptlrpc_req_finished (req);
1414 RETURN(put_user(flags, (int *)arg));
1416 case EXT3_IOC_SETFLAGS: {
1417 struct mdc_op_data *op_data;
1420 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1422 if (get_user(flags, (int *)arg))
1429 OBD_ALLOC(op_data, sizeof(*op_data));
1430 if (op_data == NULL) {
1434 ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
1436 memset(&attr, 0x0, sizeof(attr));
1437 attr.ia_attr_flags = flags;
1438 attr.ia_valid |= ATTR_ATTR_FLAG;
1440 rc = md_setattr(sbi->ll_md_exp, op_data,
1441 &attr, NULL, 0, NULL, 0, &req);
1442 OBD_FREE(op_data, sizeof(*op_data));
1444 ptlrpc_req_finished(req);
1445 if (rc != -EPERM && rc != -EACCES)
1446 CERROR("md_setattr fails: rc = %d\n", rc);
1450 ptlrpc_req_finished(req);
1452 oa->o_id = lsm->lsm_object_id;
1453 oa->o_gr = lsm->lsm_object_gr;
1454 oa->o_flags = flags;
1455 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1457 rc = obd_setattr(sbi->ll_dt_exp, oa, lsm, NULL);
1460 if (rc != -EPERM && rc != -EACCES)
1461 CERROR("md_setattr fails: rc = %d\n", rc);
1465 if (flags & EXT3_APPEND_FL)
1466 inode->i_flags |= S_APPEND;
1468 inode->i_flags &= ~S_APPEND;
1469 if (flags & EXT3_IMMUTABLE_FL)
1470 inode->i_flags |= S_IMMUTABLE;
1472 inode->i_flags &= ~S_IMMUTABLE;
1473 if (flags & EXT3_NOATIME_FL)
1474 inode->i_flags |= S_NOATIME;
1476 inode->i_flags &= ~S_NOATIME;
1487 /* this is only called in the case of forced umount. */
1488 void ll_umount_begin(struct super_block *sb)
1490 struct ll_sb_info *sbi = ll_s2sbi(sb);
1491 struct obd_device *obd;
1492 struct obd_ioctl_data ioc_data = { 0 };
1495 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb,
1496 sb->s_count, atomic_read(&sb->s_active));
1498 obd = class_exp2obd(sbi->ll_md_exp);
1500 CERROR("Invalid MDC connection handle "LPX64"\n",
1501 sbi->ll_md_exp->exp_handle.h_cookie);
1505 obd->obd_no_recov = 1;
1506 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
1507 sizeof(ioc_data), &ioc_data, NULL);
1509 obd = class_exp2obd(sbi->ll_dt_exp);
1511 CERROR("Invalid LOV connection handle "LPX64"\n",
1512 sbi->ll_dt_exp->exp_handle.h_cookie);
1517 obd->obd_no_recov = 1;
1518 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
1519 sizeof(ioc_data), &ioc_data, NULL);
1522 * really, we'd like to wait until there are no requests outstanding,
1523 * and then continue. For now, we just invalidate the requests,
1524 * schedule, and hope.
1531 int ll_prep_inode(struct obd_export *dt_exp, struct obd_export *md_exp,
1532 struct inode **inode, struct ptlrpc_request *req,
1533 int offset, struct super_block *sb)
1535 struct lustre_md md;
1538 rc = mdc_req2lustre_md(md_exp, req, offset, dt_exp, &md);
1543 ll_update_inode(*inode, &md);
1546 *inode = ll_iget(sb, id_ino(&md.body->id1), &md);
1547 if (*inode == NULL || is_bad_inode(*inode)) {
1548 /* free the lsm if we allocated one above */
1550 obd_free_memmd(dt_exp, &md.lsm);
1552 obd_free_memmd(md_exp,
1553 (struct lov_stripe_md**)&md.mea);
1555 CERROR("new_inode -fatal: rc %d\n", rc);
1562 int ll_get_fid(struct obd_export *exp, struct lustre_id *idp,
1563 char *filename, struct lustre_id *ret)
1565 struct ptlrpc_request *request = NULL;
1566 struct mds_body *body;
1569 rc = md_getattr_lock(exp, idp, filename, strlen(filename) + 1,
1572 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
1577 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
1578 LASSERT(body != NULL);
1579 LASSERT_REPSWABBED(request, 0);
1582 ptlrpc_req_finished(request);