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 | OBD_MD_FID),
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 lmd->lmd_nal == IIBNAL ||
451 lmd->lmd_nal == VIBNAL ||
452 lmd->lmd_nal == RANAL) {
453 PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);
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 err = libcfs_nal_cmd(&pcfg);
463 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
464 lcfg.lcfg_nid = lmd->lmd_server_nid;
465 lcfg.lcfg_inllen1 = strlen(peer) + 1;
466 lcfg.lcfg_inlbuf1 = peer;
467 lcfg.lcfg_nal = lmd->lmd_nal;
468 err = class_process_config(&lcfg);
470 GOTO(out_del_conn, err);
472 LCFG_INIT(lcfg, LCFG_ATTACH, name);
473 lcfg.lcfg_inlbuf1 = "mdc";
474 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
475 lcfg.lcfg_inlbuf2 = lmv_uuid.uuid;
476 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
477 err = class_process_config(&lcfg);
479 GOTO(out_del_uuid, err);
481 LCFG_INIT(lcfg, LCFG_SETUP, name);
482 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
483 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
484 lcfg.lcfg_inlbuf2 = peer;
485 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
486 err = class_process_config(&lcfg);
488 GOTO(out_detach, err);
490 obd = class_name2obd(name);
492 GOTO(out_cleanup, err = -EINVAL);
494 /* Disable initial recovery on this import */
495 err = obd_set_info(obd->obd_self_export,
496 strlen("initial_recov"), "initial_recov",
497 sizeof(allow_recov), &allow_recov);
499 GOTO(out_cleanup, err);
501 err = obd_connect(&md_conn, obd, &lmv_uuid, 0);
503 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
504 GOTO(out_cleanup, err);
507 exp = class_conn2export(&md_conn);
509 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
510 rc = class_config_process_llog(ctxt, profile, cfg);
512 CERROR("class_config_process_llog failed: rc = %d\n", rc);
514 err = obd_disconnect(exp, 0);
518 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
519 err = class_process_config(&lcfg);
524 LCFG_INIT(lcfg, LCFG_DETACH, name);
525 err = class_process_config(&lcfg);
530 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
531 lcfg.lcfg_inllen1 = strlen(peer) + 1;
532 lcfg.lcfg_inlbuf1 = peer;
533 err = class_process_config(&lcfg);
536 if (lmd->lmd_nal == SOCKNAL ||
537 lmd->lmd_nal == OPENIBNAL ||
538 lmd->lmd_nal == IIBNAL ||
539 lmd->lmd_nal == VIBNAL ||
540 lmd->lmd_nal == RANAL) {
541 PCFG_INIT(pcfg, NAL_CMD_DEL_PEER);
542 pcfg.pcfg_nal = lmd->lmd_nal;
543 pcfg.pcfg_nid = lmd->lmd_server_nid;
544 pcfg.pcfg_flags = 1; /* single_share */
545 err = libcfs_nal_cmd(&pcfg);
556 int lustre_fill_super(struct super_block *sb, void *data, int silent)
558 struct lustre_mount_data * lmd = data;
559 char *lov = NULL, *lmv = NULL;
560 struct ll_sb_info *sbi;
564 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
565 if (lmd_bad_magic(lmd))
568 sbi = lustre_init_sbi(sb);
572 sbi->ll_flags |= LL_SBI_READAHEAD;
574 if (lmd->lmd_profile) {
575 struct lustre_profile *lprof;
576 struct config_llog_instance cfg;
579 if (lmd->lmd_mds[0] == '\0') {
580 CERROR("no mds name\n");
581 GOTO(out_free, err = -EINVAL);
584 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
585 if (sbi->ll_lmd == NULL)
586 GOTO(out_free, err = -ENOMEM);
587 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
589 /* generate a string unique to this super, let's try
590 the address of the super itself.*/
591 len = (sizeof(sb) * 2) + 1;
592 OBD_ALLOC(sbi->ll_instance, len);
593 if (sbi->ll_instance == NULL)
594 GOTO(out_free, err = -ENOMEM);
595 sprintf(sbi->ll_instance, "%p", sb);
597 cfg.cfg_instance = sbi->ll_instance;
598 cfg.cfg_uuid = sbi->ll_sb_uuid;
599 cfg.cfg_local_nid = lmd->lmd_local_nid;
600 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
602 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
606 lprof = class_get_profile(lmd->lmd_profile);
608 CERROR("No profile found: %s\n", lmd->lmd_profile);
609 GOTO(out_free, err = -EINVAL);
612 OBD_FREE(lov, strlen(lov) + 1);
613 OBD_ALLOC(lov, strlen(lprof->lp_lov) +
614 strlen(sbi->ll_instance) + 2);
615 sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance);
618 OBD_FREE(lmv, strlen(lmv) + 1);
619 OBD_ALLOC(lmv, strlen(lprof->lp_lmv) +
620 strlen(sbi->ll_instance) + 2);
621 sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance);
626 GOTO(out_free, err = -EINVAL);
631 GOTO(out_free, err = -EINVAL);
634 err = lustre_common_fill_super(sb, lmv, lov);
641 OBD_FREE(lmv, strlen(lmv) + 1);
643 OBD_FREE(lov, strlen(lov) + 1);
649 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
652 if (sbi->ll_instance != NULL) {
653 struct lustre_mount_data *lmd = sbi->ll_lmd;
655 struct config_llog_instance cfg;
657 cfg.cfg_instance = sbi->ll_instance;
658 cfg.cfg_uuid = sbi->ll_sb_uuid;
660 OBD_ALLOC(cln_prof, len);
661 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
663 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
665 CERROR("Unable to process log: %s\n", cln_prof);
666 OBD_FREE(cln_prof, len);
667 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
669 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
674 } /* lustre_fill_super */
676 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
678 struct lustre_cfg lcfg;
679 struct obd_device *obd;
682 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
686 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
687 err = class_process_config(&lcfg);
689 CERROR("cleanup failed: %s\n", obd->obd_name);
693 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
694 err = class_process_config(&lcfg);
696 CERROR("detach failed: %s\n", obd->obd_name);
701 if (sbi->ll_lmd != NULL)
702 class_del_profile(sbi->ll_lmd->lmd_profile);
705 void lustre_put_super(struct super_block *sb)
707 struct obd_device *obd;
708 struct ll_sb_info *sbi = ll_s2sbi(sb);
709 int force_umount = 0;
712 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
713 obd = class_exp2obd(sbi->ll_md_exp);
715 force_umount = obd->obd_no_recov;
718 lustre_common_put_super(sb);
719 if (sbi->ll_lmd != NULL) {
721 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
723 struct config_llog_instance cfg;
726 CERROR("force umount, doing manual cleanup\n");
727 lustre_manual_cleanup(sbi);
731 cfg.cfg_instance = sbi->ll_instance;
732 cfg.cfg_uuid = sbi->ll_sb_uuid;
734 OBD_ALLOC(cln_prof, len);
735 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
737 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
739 CERROR("Unable to process log: %s, doing manual cleanup"
741 lustre_manual_cleanup(sbi);
744 OBD_FREE(cln_prof, len);
746 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
747 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
753 } /* lustre_put_super */
755 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
757 struct obd_export *md_exp = sbi->ll_md_exp;
758 struct lustre_mount_data *lmd = sbi->ll_lmd;
759 struct llog_ctxt *ctxt;
760 struct config_llog_instance cfg;
761 char *profile = lmd->lmd_profile, *name = NULL;
762 int rc, namelen = 0, version;
768 CERROR("Client not mounted with zero-conf; cannot process "
773 rc = ldlm_cli_cancel_unused(md_exp->exp_obd->obd_namespace, NULL,
774 LDLM_FL_CONFIG_CHANGE, NULL);
776 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
778 rc = obd_cancel_unused(sbi->ll_dt_exp, NULL, LDLM_FL_CONFIG_CHANGE,
781 CWARN("obd_cancel_unused(lov): %d\n", rc);
783 cfg.cfg_instance = sbi->ll_instance;
784 cfg.cfg_uuid = sbi->ll_sb_uuid;
785 cfg.cfg_local_nid = lmd->lmd_local_nid;
787 namelen = strlen(profile) + 20; /* -clean-######### */
788 OBD_ALLOC(name, namelen);
793 version = sbi->ll_config_version - 1;
794 sprintf(name, "%s-clean-%d", profile, version);
796 version = sbi->ll_config_version + 1;
797 sprintf(name, "%s-%d", profile, version);
800 CWARN("Applying configuration log %s\n", name);
802 ctxt = llog_get_context(&md_exp->exp_obd->obd_llogs,
803 LLOG_CONFIG_REPL_CTXT);
804 rc = class_config_process_llog(ctxt, name, &cfg);
806 sbi->ll_config_version = version;
807 CWARN("Finished applying configuration log %s: %d\n", name, rc);
809 if (rc == 0 && clean == 0) {
810 struct lov_desc desc;
812 valsize = sizeof(desc);
813 rc = obd_get_info(sbi->ll_dt_exp, strlen("lovdesc") + 1,
814 "lovdesc", &valsize, &desc);
816 rc = obd_init_ea_size(md_exp,
817 obd_size_diskmd(sbi->ll_dt_exp, NULL),
819 sizeof(struct llog_cookie)));
821 OBD_FREE(name, namelen);
825 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
827 struct inode *inode = NULL;
828 l_lock(&lock->l_resource->lr_namespace->ns_lock);
829 if (lock->l_ast_data) {
830 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
831 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
832 inode = igrab(lock->l_ast_data);
834 CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
835 lock->l_ast_data, lli->lli_inode_magic);
838 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
842 int null_if_equal(struct ldlm_lock *lock, void *data)
844 if (data == lock->l_ast_data) {
845 lock->l_ast_data = NULL;
847 if (lock->l_req_mode != lock->l_granted_mode)
848 LDLM_ERROR(lock,"clearing inode with ungranted lock\n");
851 return LDLM_ITER_CONTINUE;
854 void ll_clear_inode(struct inode *inode)
857 struct ll_inode_info *lli = ll_i2info(inode);
858 struct ll_sb_info *sbi = ll_i2sbi(inode);
861 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
862 inode->i_generation, inode);
864 lli->lli_inode_magic = LLI_INODE_DEAD;
865 ll_inode2id(&id, inode);
867 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
868 md_change_cbdata(sbi->ll_md_exp, &id, null_if_equal, inode);
871 obd_change_cbdata(sbi->ll_dt_exp, lli->lli_smd,
872 null_if_equal, inode);
875 obd_free_memmd(sbi->ll_dt_exp, &lli->lli_smd);
880 obd_free_memmd(sbi->ll_md_exp,
881 (struct lov_stripe_md **) &lli->lli_mea);
885 if (lli->lli_symlink_name) {
886 OBD_FREE(lli->lli_symlink_name,
887 strlen(lli->lli_symlink_name) + 1);
888 lli->lli_symlink_name = NULL;
894 /* If this inode has objects allocated to it (lsm != NULL), then the OST
895 * object(s) determine the file size and mtime. Otherwise, the MDS will
896 * keep these values until such a time that objects are allocated for it.
897 * We do the MDS operations first, as it is checking permissions for us.
898 * We don't to the MDS RPC if there is nothing that we want to store there,
899 * otherwise there is no harm in updating mtime/atime on the MDS if we are
900 * going to do an RPC anyways.
902 * If we are doing a truncate, we will send the mtime and ctime updates
903 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
904 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
907 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
909 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
910 struct ll_sb_info *sbi = ll_i2sbi(inode);
911 struct ptlrpc_request *request = NULL;
912 struct mdc_op_data *op_data;
913 int ia_valid = attr->ia_valid;
917 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
918 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
920 if (ia_valid & ATTR_SIZE) {
921 if (attr->ia_size > ll_file_maxbytes(inode)) {
922 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
923 attr->ia_size, ll_file_maxbytes(inode));
927 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
930 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
931 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
932 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
936 /* We mark all of the fields "set" so MDS/OST does not re-set them */
937 if (attr->ia_valid & ATTR_CTIME) {
938 attr->ia_ctime = CURRENT_TIME;
939 attr->ia_valid |= ATTR_CTIME_SET;
941 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
942 attr->ia_atime = CURRENT_TIME;
943 attr->ia_valid |= ATTR_ATIME_SET;
945 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
946 attr->ia_mtime = CURRENT_TIME;
947 attr->ia_valid |= ATTR_MTIME_SET;
950 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
951 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
952 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
953 LTIME_S(CURRENT_TIME));
955 attr->ia_valid &= ~ATTR_SIZE;
957 /* If only OST attributes being set on objects, don't do MDS RPC.
958 * In that case, we need to check permissions and update the local
959 * inode ourselves so we can call obdo_from_inode() always. */
960 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
963 OBD_ALLOC(op_data, sizeof(*op_data));
966 ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
968 rc = md_setattr(sbi->ll_md_exp, op_data,
969 attr, NULL, 0, NULL, 0, &request);
970 OBD_FREE(op_data, sizeof(*op_data));
972 ptlrpc_req_finished(request);
973 if (rc != -EPERM && rc != -EACCES)
974 CERROR("md_setattr fails: rc = %d\n", rc);
978 rc = mdc_req2lustre_md(sbi->ll_md_exp, request, 0,
979 sbi->ll_dt_exp, &md);
981 ptlrpc_req_finished(request);
985 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
986 * but needed to set timestamps backwards on utime. */
987 inode_setattr(inode, attr);
988 ll_update_inode(inode, &md);
989 ptlrpc_req_finished(request);
991 if (!lsm || !S_ISREG(inode->i_mode)) {
992 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
996 /* The OST doesn't check permissions, but the alternative is
997 * a gratuitous RPC to the MDS. We already rely on the client
998 * to do read/write/truncate permission checks, so is mtime OK?
1000 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
1001 /* from sys_utime() */
1002 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
1003 if (current->fsuid != inode->i_uid &&
1004 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1007 /* from inode_change_ok() */
1008 if (current->fsuid != inode->i_uid &&
1009 !capable(CAP_FOWNER))
1014 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1015 inode_setattr(inode, attr);
1018 /* We really need to get our PW lock before we change inode->i_size.
1019 * If we don't we can race with other i_size updaters on our node, like
1020 * ll_file_read. We can also race with i_size propogation to other
1021 * nodes through dirtying and writeback of final cached pages. This
1022 * last one is especially bad for racing o_append users on other
1024 if (ia_valid & ATTR_SIZE) {
1025 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1027 struct lustre_handle lockh = { 0 };
1028 int err, ast_flags = 0;
1029 /* XXX when we fix the AST intents to pass the discard-range
1030 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1032 if (attr->ia_size == 0)
1033 ast_flags = LDLM_AST_DISCARD_DATA;
1035 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1036 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1038 UP_WRITE_I_ALLOC_SEM(inode);
1039 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1040 ast_flags, &ll_i2sbi(inode)->ll_seek_stime);
1041 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1042 DOWN_WRITE_I_ALLOC_SEM(inode);
1043 down(&inode->i_sem);
1045 down(&inode->i_sem);
1046 DOWN_WRITE_I_ALLOC_SEM(inode);
1051 rc = vmtruncate(inode, attr->ia_size);
1053 /* We need to drop the semaphore here, because this unlock may
1054 * result in a cancellation, which will need the i_sem */
1056 UP_WRITE_I_ALLOC_SEM(inode);
1057 /* unlock now as we don't mind others file lockers racing with
1058 * the mds updates below? */
1059 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1060 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1061 DOWN_WRITE_I_ALLOC_SEM(inode);
1062 down(&inode->i_sem);
1064 down(&inode->i_sem);
1065 DOWN_WRITE_I_ALLOC_SEM(inode);
1068 CERROR("ll_extent_unlock failed: %d\n", err);
1072 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1073 struct obdo *oa = NULL;
1075 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1076 inode->i_ino, LTIME_S(attr->ia_mtime));
1082 oa->o_id = lsm->lsm_object_id;
1083 oa->o_gr = lsm->lsm_object_gr;
1084 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1085 obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1086 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1087 rc = obd_setattr(sbi->ll_dt_exp, oa, lsm, NULL);
1090 CERROR("obd_setattr fails: rc = %d\n", rc);
1095 int ll_setattr(struct dentry *de, struct iattr *attr)
1097 LBUG(); /* code is unused, but leave this in case of VFS changes */
1101 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1102 unsigned long max_age)
1104 struct ll_sb_info *sbi = ll_s2sbi(sb);
1105 struct obd_statfs obd_osfs;
1109 rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age);
1111 CERROR("mdc_statfs fails: rc = %d\n", rc);
1115 osfs->os_type = sb->s_magic;
1117 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1118 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1120 rc = obd_statfs(class_exp2obd(sbi->ll_dt_exp), &obd_osfs, max_age);
1122 CERROR("obd_statfs fails: rc = %d\n", rc);
1126 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1127 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1130 osfs->os_blocks = obd_osfs.os_blocks;
1131 osfs->os_bfree = obd_osfs.os_bfree;
1132 osfs->os_bavail = obd_osfs.os_bavail;
1134 /* If we don't have as many objects free on the OST as inodes
1135 * on the MDS, we reduce the total number of inodes to
1136 * compensate, so that the "inodes in use" number is correct.
1138 if (obd_osfs.os_ffree < osfs->os_ffree) {
1139 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1141 osfs->os_ffree = obd_osfs.os_ffree;
1147 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1149 struct obd_statfs osfs;
1152 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p\n", sb);
1153 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1155 /* For now we will always get up-to-date statfs values, but in the
1156 * future we may allow some amount of caching on the client (e.g.
1157 * from QOS or lprocfs updates). */
1158 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1162 statfs_unpack(sfs, &osfs);
1164 if (sizeof(sfs->f_blocks) == 4) {
1165 while (osfs.os_blocks > ~0UL) {
1168 osfs.os_blocks >>= 1;
1169 osfs.os_bfree >>= 1;
1170 osfs.os_bavail >>= 1;
1174 sfs->f_blocks = osfs.os_blocks;
1175 sfs->f_bfree = osfs.os_bfree;
1176 sfs->f_bavail = osfs.os_bavail;
1181 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1183 struct ll_inode_info *lli = ll_i2info(inode);
1184 struct lov_stripe_md *lsm = md->lsm;
1185 struct mds_body *body = md->body;
1186 struct mea *mea = md->mea;
1189 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1190 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1192 LASSERT(lsm->lsm_object_gr > 0);
1193 if (lli->lli_smd == NULL) {
1195 lli->lli_maxbytes = lsm->lsm_maxbytes;
1196 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1197 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1200 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1201 CERROR("lsm mismatch for inode %ld\n",
1203 CERROR("lli_smd:\n");
1204 dump_lsm(D_ERROR, lli->lli_smd);
1206 dump_lsm(D_ERROR, lsm);
1209 /* XXX FIXME -- We should decide on a safer (atomic) and
1210 * more elegant way to update the lsm */
1211 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1212 lli->lli_smd->lsm_oinfo[i].loi_id =
1213 lsm->lsm_oinfo[i].loi_id;
1214 lli->lli_smd->lsm_oinfo[i].loi_gr =
1215 lsm->lsm_oinfo[i].loi_gr;
1216 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1217 lsm->lsm_oinfo[i].loi_ost_idx;
1218 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1219 lsm->lsm_oinfo[i].loi_ost_gen;
1222 /* bug 2844 - limit i_blksize for broken user-space apps */
1223 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1224 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1225 if (lli->lli_smd != lsm)
1226 obd_free_memmd(ll_i2dtexp(inode), &lsm);
1230 if (lli->lli_mea == NULL) {
1233 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1234 CERROR("mea mismatch for inode %lu\n",
1239 if (lli->lli_mea != mea)
1240 obd_free_memmd(ll_i2mdexp(inode),
1241 (struct lov_stripe_md **) &mea);
1244 if (body->valid & OBD_MD_FID)
1245 id_assign_fid(&lli->lli_id, &body->id1);
1247 if (body->valid & OBD_MD_FLID)
1248 id_ino(&lli->lli_id) = id_ino(&body->id1);
1250 if (body->valid & OBD_MD_FLGENER)
1251 id_gen(&lli->lli_id) = id_gen(&body->id1);
1253 if (body->valid & OBD_MD_FLID)
1254 inode->i_ino = id_ino(&body->id1);
1255 if (body->valid & OBD_MD_FLGENER)
1256 inode->i_generation = id_gen(&body->id1);
1257 if (body->valid & OBD_MD_FLATIME)
1258 LTIME_S(inode->i_atime) = body->atime;
1259 if (body->valid & OBD_MD_FLMTIME &&
1260 body->mtime > LTIME_S(inode->i_mtime)) {
1261 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1262 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1263 LTIME_S(inode->i_mtime) = body->mtime;
1265 if (body->valid & OBD_MD_FLCTIME &&
1266 body->ctime > LTIME_S(inode->i_ctime))
1267 LTIME_S(inode->i_ctime) = body->ctime;
1268 if (body->valid & OBD_MD_FLMODE) {
1269 inode->i_mode = (inode->i_mode & S_IFMT) |
1270 (body->mode & ~S_IFMT);
1272 if (body->valid & OBD_MD_FLTYPE) {
1273 inode->i_mode = (inode->i_mode & ~S_IFMT) |
1274 (body->mode & S_IFMT);
1276 if (body->valid & OBD_MD_FLUID)
1277 inode->i_uid = body->uid;
1278 if (body->valid & OBD_MD_FLGID)
1279 inode->i_gid = body->gid;
1280 if (body->valid & OBD_MD_FLFLAGS)
1281 inode->i_flags = body->flags;
1282 if (body->valid & OBD_MD_FLNLINK)
1283 inode->i_nlink = body->nlink;
1284 if (body->valid & OBD_MD_FLRDEV)
1285 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1286 inode->i_rdev = body->rdev;
1288 inode->i_rdev = old_decode_dev(body->rdev);
1290 if (body->valid & OBD_MD_FLSIZE)
1291 inode->i_size = body->size;
1292 if (body->valid & OBD_MD_FLBLOCKS)
1293 inode->i_blocks = body->blocks;
1295 if (body->valid & OBD_MD_FLSIZE)
1296 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1298 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1299 inode->i_dev = (kdev_t)id_group(&lli->lli_id);
1301 LASSERT(id_fid(&lli->lli_id) != 0);
1304 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1305 static struct backing_dev_info ll_backing_dev_info = {
1306 .ra_pages = 0, /* No readahead */
1307 .memory_backed = 0, /* Does contribute to dirty memory */
1311 void ll_read_inode2(struct inode *inode, void *opaque)
1313 struct lustre_md *md = opaque;
1314 struct ll_inode_info *lli = ll_i2info(inode);
1317 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1318 inode->i_generation, inode);
1322 LASSERT(!lli->lli_smd);
1324 /* Core attributes from the MDS first. This is a new inode, and
1325 * the VFS doesn't zero times in the core inode so we have to do
1326 * it ourselves. They will be overwritten by either MDS or OST
1327 * attributes - we just need to make sure they aren't newer. */
1328 LTIME_S(inode->i_mtime) = 0;
1329 LTIME_S(inode->i_atime) = 0;
1330 LTIME_S(inode->i_ctime) = 0;
1333 ll_update_inode(inode, md);
1335 /* OIDEBUG(inode); */
1337 if (S_ISREG(inode->i_mode)) {
1338 inode->i_op = &ll_file_inode_operations;
1339 inode->i_fop = &ll_file_operations;
1340 inode->i_mapping->a_ops = &ll_aops;
1342 } else if (S_ISDIR(inode->i_mode)) {
1343 inode->i_op = &ll_dir_inode_operations;
1344 inode->i_fop = &ll_dir_operations;
1345 inode->i_mapping->a_ops = &ll_dir_aops;
1347 } else if (S_ISLNK(inode->i_mode)) {
1348 inode->i_op = &ll_fast_symlink_inode_operations;
1351 inode->i_op = &ll_special_inode_operations;
1353 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1354 init_special_inode(inode, inode->i_mode,
1355 kdev_t_to_nr(inode->i_rdev));
1357 /* initializing backing dev info. */
1358 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1360 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1362 lli->ll_save_ifop = inode->i_fop;
1364 if (S_ISCHR(inode->i_mode))
1365 inode->i_fop = &ll_special_chr_inode_fops;
1366 else if (S_ISBLK(inode->i_mode))
1367 inode->i_fop = &ll_special_blk_inode_fops;
1368 else if (S_ISFIFO(inode->i_mode))
1369 inode->i_fop = &ll_special_fifo_inode_fops;
1370 else if (S_ISSOCK(inode->i_mode))
1371 inode->i_fop = &ll_special_sock_inode_fops;
1373 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1376 if (lli->ll_save_ifop->owner) {
1377 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1378 lli->ll_save_ifop->owner);
1384 void ll_delete_inode(struct inode *inode)
1386 struct ll_sb_info *sbi = ll_i2sbi(inode);
1387 struct lustre_id id;
1391 ll_inode2id(&id, inode);
1393 rc = md_delete_inode(sbi->ll_md_exp, &id);
1395 CERROR("md_delete_inode() failed, error %d\n",
1403 int ll_iocontrol(struct inode *inode, struct file *file,
1404 unsigned int cmd, unsigned long arg)
1406 struct ll_sb_info *sbi = ll_i2sbi(inode);
1407 struct ptlrpc_request *req = NULL;
1412 case EXT3_IOC_GETFLAGS: {
1413 struct lustre_id id;
1414 __u64 valid = OBD_MD_FLFLAGS;
1415 struct mds_body *body;
1417 ll_inode2id(&id, inode);
1418 rc = md_getattr(sbi->ll_md_exp, &id, valid, 0, &req);
1420 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1424 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1426 if (body->flags & S_APPEND)
1427 flags |= EXT3_APPEND_FL;
1428 if (body->flags & S_IMMUTABLE)
1429 flags |= EXT3_IMMUTABLE_FL;
1430 if (body->flags & S_NOATIME)
1431 flags |= EXT3_NOATIME_FL;
1433 ptlrpc_req_finished (req);
1435 RETURN(put_user(flags, (int *)arg));
1437 case EXT3_IOC_SETFLAGS: {
1438 struct mdc_op_data *op_data;
1441 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1443 if (get_user(flags, (int *)arg))
1450 OBD_ALLOC(op_data, sizeof(*op_data));
1451 if (op_data == NULL) {
1455 ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
1457 memset(&attr, 0x0, sizeof(attr));
1458 attr.ia_attr_flags = flags;
1459 attr.ia_valid |= ATTR_ATTR_FLAG;
1461 rc = md_setattr(sbi->ll_md_exp, op_data,
1462 &attr, NULL, 0, NULL, 0, &req);
1463 OBD_FREE(op_data, sizeof(*op_data));
1465 ptlrpc_req_finished(req);
1466 if (rc != -EPERM && rc != -EACCES)
1467 CERROR("md_setattr fails: rc = %d\n", rc);
1471 ptlrpc_req_finished(req);
1473 oa->o_id = lsm->lsm_object_id;
1474 oa->o_gr = lsm->lsm_object_gr;
1475 oa->o_flags = flags;
1476 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1478 rc = obd_setattr(sbi->ll_dt_exp, oa, lsm, NULL);
1481 if (rc != -EPERM && rc != -EACCES)
1482 CERROR("md_setattr fails: rc = %d\n", rc);
1486 if (flags & EXT3_APPEND_FL)
1487 inode->i_flags |= S_APPEND;
1489 inode->i_flags &= ~S_APPEND;
1490 if (flags & EXT3_IMMUTABLE_FL)
1491 inode->i_flags |= S_IMMUTABLE;
1493 inode->i_flags &= ~S_IMMUTABLE;
1494 if (flags & EXT3_NOATIME_FL)
1495 inode->i_flags |= S_NOATIME;
1497 inode->i_flags &= ~S_NOATIME;
1508 /* this is only called in the case of forced umount. */
1509 void ll_umount_begin(struct super_block *sb)
1511 struct ll_sb_info *sbi = ll_s2sbi(sb);
1512 struct obd_device *obd;
1513 struct obd_ioctl_data ioc_data = { 0 };
1516 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb,
1517 sb->s_count, atomic_read(&sb->s_active));
1519 obd = class_exp2obd(sbi->ll_md_exp);
1521 CERROR("Invalid MDC connection handle "LPX64"\n",
1522 sbi->ll_md_exp->exp_handle.h_cookie);
1526 obd->obd_no_recov = 1;
1527 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
1528 sizeof(ioc_data), &ioc_data, NULL);
1530 obd = class_exp2obd(sbi->ll_dt_exp);
1532 CERROR("Invalid LOV connection handle "LPX64"\n",
1533 sbi->ll_dt_exp->exp_handle.h_cookie);
1538 obd->obd_no_recov = 1;
1539 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
1540 sizeof(ioc_data), &ioc_data, NULL);
1543 * really, we'd like to wait until there are no requests outstanding,
1544 * and then continue. For now, we just invalidate the requests,
1545 * schedule, and hope.
1552 int ll_prep_inode(struct obd_export *dt_exp, struct obd_export *md_exp,
1553 struct inode **inode, struct ptlrpc_request *req,
1554 int offset, struct super_block *sb)
1556 struct lustre_md md;
1559 rc = mdc_req2lustre_md(md_exp, req, offset, dt_exp, &md);
1564 ll_update_inode(*inode, &md);
1567 *inode = ll_iget(sb, id_ino(&md.body->id1), &md);
1568 if (*inode == NULL || is_bad_inode(*inode)) {
1569 /* free the lsm if we allocated one above */
1571 obd_free_memmd(dt_exp, &md.lsm);
1573 obd_free_memmd(md_exp,
1574 (struct lov_stripe_md**)&md.mea);
1576 CERROR("new_inode -fatal: rc %d\n", rc);
1583 int ll_get_fid(struct obd_export *exp, struct lustre_id *idp,
1584 char *filename, struct lustre_id *ret)
1586 struct ptlrpc_request *request = NULL;
1587 struct mds_body *body;
1590 rc = md_getattr_lock(exp, idp, filename, strlen(filename) + 1,
1591 OBD_MD_FID, 0, &request);
1593 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
1598 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
1599 LASSERT(body != NULL);
1600 LASSERT_REPSWABBED(request, 0);
1603 ptlrpc_req_finished(request);