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_lov_desc(struct ll_sb_info *sbi)
100 valsize = sizeof(sbi->ll_lov_desc);
101 memset(&sbi->ll_lov_desc, 0, sizeof(sbi->ll_lov_desc));
102 rc = obd_get_info(sbi->ll_lov_exp, strlen("lovdesc") + 1,
103 "lovdesc", &valsize, &sbi->ll_lov_desc);
107 int lustre_init_lmv_desc(struct ll_sb_info *sbi)
112 valsize = sizeof(sbi->ll_lmv_desc);
113 memset(&sbi->ll_lmv_desc, 0, sizeof(sbi->ll_lmv_desc));
114 rc = obd_get_info(sbi->ll_lmv_exp, strlen("lmvdesc") + 1,
115 "lmvdesc", &valsize, &sbi->ll_lmv_desc);
119 int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
121 struct ll_sb_info *sbi = ll_s2sbi(sb);
122 struct ptlrpc_request *request = NULL;
123 struct lustre_handle lov_conn = {0, };
124 struct lustre_handle lmv_conn = {0, };
125 struct inode *root = NULL;
126 struct obd_device *obd;
127 struct obd_statfs osfs;
133 obd = class_name2obd(lmv);
135 CERROR("MDC %s: not setup or attached\n", lmv);
139 if (proc_lustre_fs_root) {
140 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
143 CERROR("could not register mount in /proc/lustre");
146 err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, OBD_OPT_REAL_CLIENT);
148 CERROR("An MDS (mdc %s) is performing recovery, of which this"
149 " client is not a part. Please wait for recovery to "
150 "complete, abort, or time out.\n", lmv);
153 CERROR("cannot connect to %s: rc = %d\n", lmv, err);
156 sbi->ll_lmv_exp = class_conn2export(&lmv_conn);
158 lustre_init_lmv_desc(sbi);
160 err = obd_statfs(obd, &osfs, jiffies - HZ);
164 if (!osfs.os_bsize) {
165 CERROR("Invalid block size is detected.");
169 sb->s_magic = LL_SUPER_MAGIC;
170 sb->s_blocksize = osfs.os_bsize;
171 sb->s_blocksize_bits = log2(osfs.os_bsize);
172 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
174 devno = get_uuid2int(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid,
175 strlen(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid));
179 obd = class_name2obd(lov);
181 CERROR("OSC %s: not setup or attached\n", lov);
185 err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, OBD_OPT_REAL_CLIENT);
187 CERROR("An OST (osc %s) is performing recovery, of which this"
188 " client is not a part. Please wait for recovery to "
189 "complete, abort, or time out.\n", lov);
192 CERROR("cannot connect to %s: rc = %d\n", lov, err);
195 sbi->ll_lov_exp = class_conn2export(&lov_conn);
197 err = lustre_init_lov_desc(sbi);
199 int mdsize = obd_size_diskmd(sbi->ll_lov_exp, NULL);
200 obd_init_ea_size(sbi->ll_lmv_exp, mdsize,
201 sbi->ll_lov_desc.ld_tgt_count *
202 sizeof(struct llog_cookie));
205 err = md_getstatus(sbi->ll_lmv_exp, &sbi->ll_rootid);
207 CERROR("cannot mds_connect: rc = %d\n", err);
210 CDEBUG(D_SUPER, "rootid "DLID4"\n", OLID4(&sbi->ll_rootid));
212 sb->s_op = &lustre_super_operations;
215 * XXX: move this to after cbd setup? */
216 err = md_getattr(sbi->ll_lmv_exp, &sbi->ll_rootid,
217 OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID,
220 CERROR("md_getattr failed for root: rc = %d\n", err);
224 err = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0,
225 sbi->ll_lov_exp, &md);
227 CERROR("failed to understand root inode md: rc = %d\n", err);
228 ptlrpc_req_finished(request);
232 LASSERT(id_ino(&sbi->ll_rootid) != 0);
233 root = ll_iget(sb, id_ino(&sbi->ll_rootid), &md);
235 ptlrpc_req_finished(request);
237 if (root == NULL || is_bad_inode(root)) {
238 CERROR("lustre_lite: bad iget4 for root\n");
239 GOTO(out_root, err = -EBADF);
242 err = ll_close_thread_start(&sbi->ll_lcq);
244 CERROR("cannot start close thread: rc %d\n", err);
248 ll_gns_add_timer(sbi);
250 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x, backing dev
251 info assigned to inode mapping is used for determining maximal
253 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
254 /* bug 2805 - set VM readahead to zero */
255 vm_max_readahead = vm_min_readahead = 0;
258 sb->s_root = d_alloc_root(root);
261 CWARN("Enabling PDIROPS\n");
262 sb->s_flags |= S_PDIROPS;
270 obd_disconnect(sbi->ll_lov_exp, 0);
272 obd_disconnect(sbi->ll_lmv_exp, 0);
274 lprocfs_unregister_mountpoint(sbi);
278 void lustre_common_put_super(struct super_block *sb)
280 struct ll_sb_info *sbi = ll_s2sbi(sb);
281 struct hlist_node *tmp, *next;
284 ll_gns_del_timer(sbi);
285 ll_close_thread_shutdown(sbi->ll_lcq);
287 list_del(&sbi->ll_conn_chain);
288 obd_disconnect(sbi->ll_lov_exp, 0);
290 lprocfs_unregister_mountpoint(sbi);
291 if (sbi->ll_proc_root) {
292 lprocfs_remove(sbi->ll_proc_root);
293 sbi->ll_proc_root = NULL;
296 obd_disconnect(sbi->ll_lmv_exp, 0);
298 // We do this to get rid of orphaned dentries. That is not really trw.
299 spin_lock(&dcache_lock);
300 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
301 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
302 CWARN("orphan dentry %*s (%p) at unmount\n",
303 dentry->d_name.len, dentry->d_name.name, dentry);
304 shrink_dcache_parent(dentry);
306 spin_unlock(&dcache_lock);
310 char *ll_read_opt(const char *opt, char *data)
316 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
317 if (strncmp(opt, data, strlen(opt)))
319 if ((value = strchr(data, '=')) == NULL)
323 OBD_ALLOC(retval, strlen(value) + 1);
325 CERROR("out of memory!\n");
329 memcpy(retval, value, strlen(value)+1);
330 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
334 int ll_set_opt(const char *opt, char *data, int fl)
338 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
339 if (strncmp(opt, data, strlen(opt)))
345 void ll_options(char *options, char **lov, char **lmv, int *flags)
348 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
349 char *opt_ptr = options;
358 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
359 for (this_char = strtok (options, ",");
361 this_char = strtok (NULL, ",")) {
363 while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
365 CDEBUG(D_SUPER, "this_char %s\n", this_char);
366 if (!*lov && (*lov = ll_read_opt("osc", this_char)))
368 if (!*lmv && (*lmv = ll_read_opt("mdc", this_char)))
370 if (!(*flags & LL_SBI_NOLCK) &&
371 ((*flags) = (*flags) |
372 ll_set_opt("nolock", this_char,
380 void ll_lli_init(struct ll_inode_info *lli)
382 sema_init(&lli->lli_open_sem, 1);
384 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
385 spin_lock_init(&lli->lli_lock);
386 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
387 lli->lli_inode_magic = LLI_INODE_MAGIC;
388 memset(&lli->lli_id, 0, sizeof(lli->lli_id));
391 int ll_fill_super(struct super_block *sb, void *data, int silent)
393 struct ll_sb_info *sbi;
399 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
401 sbi = lustre_init_sbi(sb);
405 sbi->ll_flags |= LL_SBI_READAHEAD;
406 ll_options(data, &lov, &lmv, &sbi->ll_flags);
410 GOTO(out, err = -EINVAL);
415 GOTO(out, err = -EINVAL);
418 err = lustre_common_fill_super(sb, lmv, lov);
425 OBD_FREE(lmv, strlen(lmv) + 1);
427 OBD_FREE(lov, strlen(lov) + 1);
429 } /* ll_read_super */
431 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
432 struct config_llog_instance *cfg, int allow_recov)
434 struct lustre_cfg lcfg;
435 struct portals_cfg pcfg;
436 char *peer = "MDS_PEER_UUID";
437 struct obd_device *obd;
438 struct lustre_handle lmv_conn = {0, };
439 struct obd_export *exp;
440 char *name = "mdc_dev";
442 struct obd_uuid lmv_uuid;
443 struct llog_ctxt *ctxt;
448 if (lmd_bad_magic(lmd))
451 generate_random_uuid(uuid);
452 class_uuid_unparse(uuid, &lmv_uuid);
454 if (lmd->lmd_local_nid) {
455 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
456 pcfg.pcfg_nal = lmd->lmd_nal;
457 pcfg.pcfg_nid = lmd->lmd_local_nid;
458 err = libcfs_nal_cmd(&pcfg);
463 if (lmd->lmd_nal == SOCKNAL ||
464 lmd->lmd_nal == OPENIBNAL) {
465 PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);
466 pcfg.pcfg_nal = lmd->lmd_nal;
467 pcfg.pcfg_nid = lmd->lmd_server_nid;
468 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
469 pcfg.pcfg_misc = lmd->lmd_port;
470 pcfg.pcfg_size = 8388608;
471 pcfg.pcfg_flags = 0x4; /*share*/
472 err = libcfs_nal_cmd(&pcfg);
477 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
478 lcfg.lcfg_nid = lmd->lmd_server_nid;
479 lcfg.lcfg_inllen1 = strlen(peer) + 1;
480 lcfg.lcfg_inlbuf1 = peer;
481 lcfg.lcfg_nal = lmd->lmd_nal;
482 err = class_process_config(&lcfg);
484 GOTO(out_del_conn, err);
486 LCFG_INIT(lcfg, LCFG_ATTACH, name);
487 lcfg.lcfg_inlbuf1 = "mdc";
488 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
489 lcfg.lcfg_inlbuf2 = lmv_uuid.uuid;
490 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
491 err = class_process_config(&lcfg);
493 GOTO(out_del_uuid, err);
495 LCFG_INIT(lcfg, LCFG_SETUP, name);
496 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
497 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
498 lcfg.lcfg_inlbuf2 = peer;
499 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
500 err = class_process_config(&lcfg);
502 GOTO(out_detach, err);
504 obd = class_name2obd(name);
506 GOTO(out_cleanup, err = -EINVAL);
508 /* Disable initial recovery on this import */
509 err = obd_set_info(obd->obd_self_export,
510 strlen("initial_recov"), "initial_recov",
511 sizeof(allow_recov), &allow_recov);
513 GOTO(out_cleanup, err);
515 err = obd_connect(&lmv_conn, obd, &lmv_uuid, 0);
517 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
518 GOTO(out_cleanup, err);
521 exp = class_conn2export(&lmv_conn);
523 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
524 rc = class_config_process_llog(ctxt, profile, cfg);
526 CERROR("class_config_process_llog failed: rc = %d\n", rc);
528 err = obd_disconnect(exp, 0);
532 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
533 err = class_process_config(&lcfg);
538 LCFG_INIT(lcfg, LCFG_DETACH, name);
539 err = class_process_config(&lcfg);
544 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
545 lcfg.lcfg_inllen1 = strlen(peer) + 1;
546 lcfg.lcfg_inlbuf1 = peer;
547 err = class_process_config(&lcfg);
550 if (lmd->lmd_nal == SOCKNAL ||
551 lmd->lmd_nal == OPENIBNAL) {
552 PCFG_INIT(pcfg, NAL_CMD_DEL_PEER);
553 pcfg.pcfg_nal = lmd->lmd_nal;
554 pcfg.pcfg_nid = lmd->lmd_server_nid;
555 pcfg.pcfg_flags = 1; /* single_share */
556 err = libcfs_nal_cmd(&pcfg);
567 int lustre_fill_super(struct super_block *sb, void *data, int silent)
569 struct lustre_mount_data * lmd = data;
570 char *lov = NULL, *lmv = NULL;
571 struct ll_sb_info *sbi;
575 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
576 if (lmd_bad_magic(lmd))
579 sbi = lustre_init_sbi(sb);
583 sbi->ll_flags |= LL_SBI_READAHEAD;
585 if (lmd->lmd_profile) {
586 struct lustre_profile *lprof;
587 struct config_llog_instance cfg;
590 if (lmd->lmd_mds[0] == '\0') {
591 CERROR("no mds name\n");
592 GOTO(out_free, err = -EINVAL);
595 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
596 if (sbi->ll_lmd == NULL)
597 GOTO(out_free, err = -ENOMEM);
598 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
600 /* generate a string unique to this super, let's try
601 the address of the super itself.*/
602 len = (sizeof(sb) * 2) + 1;
603 OBD_ALLOC(sbi->ll_instance, len);
604 if (sbi->ll_instance == NULL)
605 GOTO(out_free, err = -ENOMEM);
606 sprintf(sbi->ll_instance, "%p", sb);
608 cfg.cfg_instance = sbi->ll_instance;
609 cfg.cfg_uuid = sbi->ll_sb_uuid;
610 cfg.cfg_local_nid = lmd->lmd_local_nid;
611 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
613 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
617 lprof = class_get_profile(lmd->lmd_profile);
619 CERROR("No profile found: %s\n", lmd->lmd_profile);
620 GOTO(out_free, err = -EINVAL);
623 OBD_FREE(lov, strlen(lov) + 1);
624 OBD_ALLOC(lov, strlen(lprof->lp_lov) +
625 strlen(sbi->ll_instance) + 2);
626 sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance);
629 OBD_FREE(lmv, strlen(lmv) + 1);
630 OBD_ALLOC(lmv, strlen(lprof->lp_lmv) +
631 strlen(sbi->ll_instance) + 2);
632 sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance);
637 GOTO(out_free, err = -EINVAL);
642 GOTO(out_free, err = -EINVAL);
645 err = lustre_common_fill_super(sb, lmv, lov);
652 OBD_FREE(lmv, strlen(lmv) + 1);
654 OBD_FREE(lov, strlen(lov) + 1);
660 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
663 if (sbi->ll_instance != NULL) {
664 struct lustre_mount_data *lmd = sbi->ll_lmd;
666 struct config_llog_instance cfg;
668 cfg.cfg_instance = sbi->ll_instance;
669 cfg.cfg_uuid = sbi->ll_sb_uuid;
671 OBD_ALLOC(cln_prof, len);
672 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
674 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
676 CERROR("Unable to process log: %s\n", cln_prof);
677 OBD_FREE(cln_prof, len);
678 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
680 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
685 } /* lustre_fill_super */
687 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
689 struct lustre_cfg lcfg;
690 struct obd_device *obd;
693 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
697 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
698 err = class_process_config(&lcfg);
700 CERROR("cleanup failed: %s\n", obd->obd_name);
704 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
705 err = class_process_config(&lcfg);
707 CERROR("detach failed: %s\n", obd->obd_name);
712 if (sbi->ll_lmd != NULL)
713 class_del_profile(sbi->ll_lmd->lmd_profile);
716 void lustre_put_super(struct super_block *sb)
718 struct obd_device *obd;
719 struct ll_sb_info *sbi = ll_s2sbi(sb);
720 int force_umount = 0;
723 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
724 obd = class_exp2obd(sbi->ll_lmv_exp);
726 force_umount = obd->obd_no_recov;
729 lustre_common_put_super(sb);
730 if (sbi->ll_lmd != NULL) {
732 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
734 struct config_llog_instance cfg;
737 CERROR("force umount, doing manual cleanup\n");
738 lustre_manual_cleanup(sbi);
742 cfg.cfg_instance = sbi->ll_instance;
743 cfg.cfg_uuid = sbi->ll_sb_uuid;
745 OBD_ALLOC(cln_prof, len);
746 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
748 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
750 CERROR("Unable to process log: %s, doing manual cleanup"
752 lustre_manual_cleanup(sbi);
755 OBD_FREE(cln_prof, len);
757 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
758 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
764 } /* lustre_put_super */
766 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
768 struct obd_export *lmv_exp = sbi->ll_lmv_exp;
769 struct lustre_mount_data *lmd = sbi->ll_lmd;
770 struct llog_ctxt *ctxt;
771 struct config_llog_instance cfg;
772 char *profile = lmd->lmd_profile, *name = NULL;
773 int rc, namelen = 0, version;
779 CERROR("Client not mounted with zero-conf; cannot process "
784 rc = ldlm_cli_cancel_unused(lmv_exp->exp_obd->obd_namespace, NULL,
785 LDLM_FL_CONFIG_CHANGE, NULL);
787 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
789 rc = obd_cancel_unused(sbi->ll_lov_exp, NULL, LDLM_FL_CONFIG_CHANGE,
792 CWARN("obd_cancel_unused(lov): %d\n", rc);
794 cfg.cfg_instance = sbi->ll_instance;
795 cfg.cfg_uuid = sbi->ll_sb_uuid;
796 cfg.cfg_local_nid = lmd->lmd_local_nid;
798 namelen = strlen(profile) + 20; /* -clean-######### */
799 OBD_ALLOC(name, namelen);
804 version = sbi->ll_config_version - 1;
805 sprintf(name, "%s-clean-%d", profile, version);
807 version = sbi->ll_config_version + 1;
808 sprintf(name, "%s-%d", profile, version);
811 CWARN("Applying configuration log %s\n", name);
813 ctxt = llog_get_context(&lmv_exp->exp_obd->obd_llogs,
814 LLOG_CONFIG_REPL_CTXT);
815 rc = class_config_process_llog(ctxt, name, &cfg);
817 sbi->ll_config_version = version;
818 CWARN("Finished applying configuration log %s: %d\n", name, rc);
820 if (rc == 0 && clean == 0) {
821 struct lov_desc desc;
823 valsize = sizeof(desc);
824 rc = obd_get_info(sbi->ll_lov_exp, strlen("lovdesc") + 1,
825 "lovdesc", &valsize, &desc);
827 rc = obd_init_ea_size(lmv_exp,
828 obd_size_diskmd(sbi->ll_lov_exp, NULL),
830 sizeof(struct llog_cookie)));
832 OBD_FREE(name, namelen);
836 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
838 struct inode *inode = NULL;
839 l_lock(&lock->l_resource->lr_namespace->ns_lock);
840 if (lock->l_ast_data) {
841 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
842 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
843 inode = igrab(lock->l_ast_data);
845 CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
846 lock->l_ast_data, lli->lli_inode_magic);
849 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
853 int null_if_equal(struct ldlm_lock *lock, void *data)
855 if (data == lock->l_ast_data) {
856 lock->l_ast_data = NULL;
858 if (lock->l_req_mode != lock->l_granted_mode)
859 LDLM_ERROR(lock,"clearing inode with ungranted lock\n");
862 return LDLM_ITER_CONTINUE;
865 void ll_clear_inode(struct inode *inode)
868 struct ll_inode_info *lli = ll_i2info(inode);
869 struct ll_sb_info *sbi = ll_i2sbi(inode);
872 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
873 inode->i_generation, inode);
875 lli->lli_inode_magic = LLI_INODE_DEAD;
876 ll_inode2id(&id, inode);
878 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
879 md_change_cbdata(sbi->ll_lmv_exp, &id, null_if_equal, inode);
882 obd_change_cbdata(sbi->ll_lov_exp, lli->lli_smd,
883 null_if_equal, inode);
886 obd_free_memmd(sbi->ll_lov_exp, &lli->lli_smd);
891 obd_free_memmd(sbi->ll_lmv_exp,
892 (struct lov_stripe_md **) &lli->lli_mea);
896 if (lli->lli_symlink_name) {
897 OBD_FREE(lli->lli_symlink_name,
898 strlen(lli->lli_symlink_name) + 1);
899 lli->lli_symlink_name = NULL;
905 /* If this inode has objects allocated to it (lsm != NULL), then the OST
906 * object(s) determine the file size and mtime. Otherwise, the MDS will
907 * keep these values until such a time that objects are allocated for it.
908 * We do the MDS operations first, as it is checking permissions for us.
909 * We don't to the MDS RPC if there is nothing that we want to store there,
910 * otherwise there is no harm in updating mtime/atime on the MDS if we are
911 * going to do an RPC anyways.
913 * If we are doing a truncate, we will send the mtime and ctime updates
914 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
915 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
918 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
920 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
921 struct ll_sb_info *sbi = ll_i2sbi(inode);
922 struct ptlrpc_request *request = NULL;
923 struct mdc_op_data op_data;
924 int ia_valid = attr->ia_valid;
928 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
929 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
931 if (ia_valid & ATTR_SIZE) {
932 if (attr->ia_size > ll_file_maxbytes(inode)) {
933 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
934 attr->ia_size, ll_file_maxbytes(inode));
938 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
941 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
942 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
943 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
947 /* We mark all of the fields "set" so MDS/OST does not re-set them */
948 if (attr->ia_valid & ATTR_CTIME) {
949 attr->ia_ctime = CURRENT_TIME;
950 attr->ia_valid |= ATTR_CTIME_SET;
952 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
953 attr->ia_atime = CURRENT_TIME;
954 attr->ia_valid |= ATTR_ATIME_SET;
956 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
957 attr->ia_mtime = CURRENT_TIME;
958 attr->ia_valid |= ATTR_MTIME_SET;
961 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
962 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
963 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
964 LTIME_S(CURRENT_TIME));
966 attr->ia_valid &= ~ATTR_SIZE;
968 /* If only OST attributes being set on objects, don't do MDS RPC.
969 * In that case, we need to check permissions and update the local
970 * inode ourselves so we can call obdo_from_inode() always. */
971 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
973 ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
975 rc = md_setattr(sbi->ll_lmv_exp, &op_data,
976 attr, NULL, 0, NULL, 0, &request);
978 ptlrpc_req_finished(request);
979 if (rc != -EPERM && rc != -EACCES)
980 CERROR("md_setattr fails: rc = %d\n", rc);
984 rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0,
985 sbi->ll_lov_exp, &md);
987 ptlrpc_req_finished(request);
991 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
992 * but needed to set timestamps backwards on utime. */
993 inode_setattr(inode, attr);
994 ll_update_inode(inode, &md);
995 ptlrpc_req_finished(request);
997 if (!lsm || !S_ISREG(inode->i_mode)) {
998 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
1002 /* The OST doesn't check permissions, but the alternative is
1003 * a gratuitous RPC to the MDS. We already rely on the client
1004 * to do read/write/truncate permission checks, so is mtime OK?
1006 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
1007 /* from sys_utime() */
1008 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
1009 if (current->fsuid != inode->i_uid &&
1010 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1013 /* from inode_change_ok() */
1014 if (current->fsuid != inode->i_uid &&
1015 !capable(CAP_FOWNER))
1020 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1021 inode_setattr(inode, attr);
1024 /* We really need to get our PW lock before we change inode->i_size.
1025 * If we don't we can race with other i_size updaters on our node, like
1026 * ll_file_read. We can also race with i_size propogation to other
1027 * nodes through dirtying and writeback of final cached pages. This
1028 * last one is especially bad for racing o_append users on other
1030 if (ia_valid & ATTR_SIZE) {
1031 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1033 struct lustre_handle lockh = { 0 };
1034 int err, ast_flags = 0;
1035 /* XXX when we fix the AST intents to pass the discard-range
1036 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1038 if (attr->ia_size == 0)
1039 ast_flags = LDLM_AST_DISCARD_DATA;
1041 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1042 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1044 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1045 ast_flags, &ll_i2sbi(inode)->ll_seek_stime);
1046 down(&inode->i_sem);
1050 rc = vmtruncate(inode, attr->ia_size);
1052 /* We need to drop the semaphore here, because this unlock may
1053 * result in a cancellation, which will need the i_sem */
1055 /* unlock now as we don't mind others file lockers racing with
1056 * the mds updates below? */
1057 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1058 down(&inode->i_sem);
1060 CERROR("ll_extent_unlock failed: %d\n", err);
1064 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1067 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1068 inode->i_ino, LTIME_S(attr->ia_mtime));
1069 oa.o_id = lsm->lsm_object_id;
1070 oa.o_gr = lsm->lsm_object_gr;
1071 oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1072 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1073 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1074 rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL);
1076 CERROR("obd_setattr fails: rc=%d\n", rc);
1081 int ll_setattr(struct dentry *de, struct iattr *attr)
1083 LBUG(); /* code is unused, but leave this in case of VFS changes */
1087 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1088 unsigned long max_age)
1090 struct ll_sb_info *sbi = ll_s2sbi(sb);
1091 struct obd_statfs obd_osfs;
1095 rc = obd_statfs(class_exp2obd(sbi->ll_lmv_exp), osfs, max_age);
1097 CERROR("mdc_statfs fails: rc = %d\n", rc);
1101 osfs->os_type = sb->s_magic;
1103 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1104 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1106 rc = obd_statfs(class_exp2obd(sbi->ll_lov_exp), &obd_osfs, max_age);
1108 CERROR("obd_statfs fails: rc = %d\n", rc);
1112 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1113 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1116 osfs->os_blocks = obd_osfs.os_blocks;
1117 osfs->os_bfree = obd_osfs.os_bfree;
1118 osfs->os_bavail = obd_osfs.os_bavail;
1120 /* If we don't have as many objects free on the OST as inodes
1121 * on the MDS, we reduce the total number of inodes to
1122 * compensate, so that the "inodes in use" number is correct.
1124 if (obd_osfs.os_ffree < osfs->os_ffree) {
1125 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1127 osfs->os_ffree = obd_osfs.os_ffree;
1133 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1135 struct obd_statfs osfs;
1138 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p\n", sb);
1139 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1141 /* For now we will always get up-to-date statfs values, but in the
1142 * future we may allow some amount of caching on the client (e.g.
1143 * from QOS or lprocfs updates). */
1144 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1148 statfs_unpack(sfs, &osfs);
1150 if (sizeof(sfs->f_blocks) == 4) {
1151 while (osfs.os_blocks > ~0UL) {
1154 osfs.os_blocks >>= 1;
1155 osfs.os_bfree >>= 1;
1156 osfs.os_bavail >>= 1;
1160 sfs->f_blocks = osfs.os_blocks;
1161 sfs->f_bfree = osfs.os_bfree;
1162 sfs->f_bavail = osfs.os_bavail;
1167 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1169 struct ll_sb_info *sbi = ll_s2sbi(inode->i_sb);
1170 struct ll_inode_info *lli = ll_i2info(inode);
1171 struct lov_stripe_md *lsm = md->lsm;
1172 struct mds_body *body = md->body;
1173 struct mea *mea = md->mea;
1176 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1177 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1179 LASSERT(lsm->lsm_object_gr > 0);
1180 if (lli->lli_smd == NULL) {
1182 lli->lli_maxbytes = lsm->lsm_maxbytes;
1183 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1184 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1187 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1188 CERROR("lsm mismatch for inode %ld\n",
1190 CERROR("lli_smd:\n");
1191 dump_lsm(D_ERROR, lli->lli_smd);
1193 dump_lsm(D_ERROR, lsm);
1196 /* XXX FIXME -- We should decide on a safer (atomic) and
1197 * more elegant way to update the lsm */
1198 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1199 lli->lli_smd->lsm_oinfo[i].loi_id =
1200 lsm->lsm_oinfo[i].loi_id;
1201 lli->lli_smd->lsm_oinfo[i].loi_gr =
1202 lsm->lsm_oinfo[i].loi_gr;
1203 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1204 lsm->lsm_oinfo[i].loi_ost_idx;
1205 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1206 lsm->lsm_oinfo[i].loi_ost_gen;
1209 /* bug 2844 - limit i_blksize for broken user-space apps */
1210 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1211 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1212 if (lli->lli_smd != lsm)
1213 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1217 if (lli->lli_mea == NULL) {
1220 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1221 CERROR("mea mismatch for inode %lu\n",
1226 if (lli->lli_mea != mea)
1227 obd_free_memmd(ll_i2lmvexp(inode),
1228 (struct lov_stripe_md **) &mea);
1232 * updating inode lustre id. We try optimize things a little bit here,
1233 * thus do not do it all the time.
1235 if (body->valid & OBD_MD_FID) {
1236 LASSERT(id_fid(&body->id1) != 0);
1237 id_assign_fid(&lli->lli_id, &body->id1);
1240 if ((body->valid & OBD_MD_FLID) || (body->valid & OBD_MD_FLGENER))
1241 id_assign_stc(&lli->lli_id, &body->id1);
1243 if (body->valid & OBD_MD_FLID)
1244 inode->i_ino = id_ino(&body->id1);
1245 if (body->valid & OBD_MD_FLGENER)
1246 inode->i_generation = id_gen(&body->id1);
1247 if (body->valid & OBD_MD_FLATIME)
1248 LTIME_S(inode->i_atime) = body->atime;
1249 if (body->valid & OBD_MD_FLMTIME &&
1250 body->mtime > LTIME_S(inode->i_mtime)) {
1251 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1252 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1253 LTIME_S(inode->i_mtime) = body->mtime;
1255 if (body->valid & OBD_MD_FLCTIME &&
1256 body->ctime > LTIME_S(inode->i_ctime))
1257 LTIME_S(inode->i_ctime) = body->ctime;
1258 if (body->valid & OBD_MD_FLMODE) {
1259 inode->i_mode = (inode->i_mode & S_IFMT) |
1260 (body->mode & ~S_IFMT);
1262 if (body->valid & OBD_MD_FLTYPE) {
1263 inode->i_mode = (inode->i_mode & ~S_IFMT) |
1264 (body->mode & S_IFMT);
1266 if (body->valid & OBD_MD_FLUID)
1267 inode->i_uid = body->uid;
1268 if (body->valid & OBD_MD_FLGID)
1269 inode->i_gid = body->gid;
1270 if (body->valid & OBD_MD_FLFLAGS)
1271 inode->i_flags = body->flags;
1272 if (body->valid & OBD_MD_FLNLINK)
1273 inode->i_nlink = body->nlink;
1274 if (body->valid & OBD_MD_FLRDEV)
1275 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1276 inode->i_rdev = body->rdev;
1278 inode->i_rdev = old_decode_dev(body->rdev);
1280 if (body->valid & OBD_MD_FLSIZE)
1281 inode->i_size = body->size;
1282 if (body->valid & OBD_MD_FLBLOCKS)
1283 inode->i_blocks = body->blocks;
1285 if (body->valid & OBD_MD_FLSIZE)
1286 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1288 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1289 inode->i_dev = (kdev_t)id_group(&lli->lli_id);
1291 LASSERT(id_fid(&lli->lli_id) != 0);
1293 LASSERT(!sbi->ll_lmv_desc.ld_tgt_count ||
1294 id_group(&lli->lli_id) < sbi->ll_lmv_desc.ld_tgt_count);
1297 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1298 static struct backing_dev_info ll_backing_dev_info = {
1299 .ra_pages = 0, /* No readahead */
1300 .memory_backed = 0, /* Does contribute to dirty memory */
1304 void ll_read_inode2(struct inode *inode, void *opaque)
1306 struct lustre_md *md = opaque;
1307 struct ll_inode_info *lli = ll_i2info(inode);
1310 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1311 inode->i_generation, inode);
1315 LASSERT(!lli->lli_smd);
1317 /* Core attributes from the MDS first. This is a new inode, and
1318 * the VFS doesn't zero times in the core inode so we have to do
1319 * it ourselves. They will be overwritten by either MDS or OST
1320 * attributes - we just need to make sure they aren't newer. */
1321 LTIME_S(inode->i_mtime) = 0;
1322 LTIME_S(inode->i_atime) = 0;
1323 LTIME_S(inode->i_ctime) = 0;
1326 ll_update_inode(inode, md);
1328 /* OIDEBUG(inode); */
1330 if (S_ISREG(inode->i_mode)) {
1331 inode->i_op = &ll_file_inode_operations;
1332 inode->i_fop = &ll_file_operations;
1333 inode->i_mapping->a_ops = &ll_aops;
1335 } else if (S_ISDIR(inode->i_mode)) {
1336 inode->i_op = &ll_dir_inode_operations;
1337 inode->i_fop = &ll_dir_operations;
1338 inode->i_mapping->a_ops = &ll_dir_aops;
1340 } else if (S_ISLNK(inode->i_mode)) {
1341 inode->i_op = &ll_fast_symlink_inode_operations;
1344 inode->i_op = &ll_special_inode_operations;
1346 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1347 init_special_inode(inode, inode->i_mode,
1348 kdev_t_to_nr(inode->i_rdev));
1350 /* initializing backing dev info. */
1351 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1353 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1355 lli->ll_save_ifop = inode->i_fop;
1357 if (S_ISCHR(inode->i_mode))
1358 inode->i_fop = &ll_special_chr_inode_fops;
1359 else if (S_ISBLK(inode->i_mode))
1360 inode->i_fop = &ll_special_blk_inode_fops;
1361 else if (S_ISFIFO(inode->i_mode))
1362 inode->i_fop = &ll_special_fifo_inode_fops;
1363 else if (S_ISSOCK(inode->i_mode))
1364 inode->i_fop = &ll_special_sock_inode_fops;
1366 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1369 if (lli->ll_save_ifop->owner) {
1370 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1371 lli->ll_save_ifop->owner);
1377 void ll_delete_inode(struct inode *inode)
1380 struct lustre_id id;
1381 struct ll_sb_info *sbi = ll_i2sbi(inode);
1384 ll_inode2id(&id, inode);
1386 rc = md_delete_object(sbi->ll_lmv_exp, &id);
1388 CERROR("md_delete_object() failed, error %d.\n",
1396 int ll_iocontrol(struct inode *inode, struct file *file,
1397 unsigned int cmd, unsigned long arg)
1399 struct ll_sb_info *sbi = ll_i2sbi(inode);
1400 struct ptlrpc_request *req = NULL;
1405 case EXT3_IOC_GETFLAGS: {
1406 struct lustre_id id;
1407 unsigned long valid = OBD_MD_FLFLAGS;
1408 struct mds_body *body;
1410 ll_inode2id(&id, inode);
1411 rc = md_getattr(sbi->ll_lmv_exp, &id, valid, 0, &req);
1413 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1417 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1419 if (body->flags & S_APPEND)
1420 flags |= EXT3_APPEND_FL;
1421 if (body->flags & S_IMMUTABLE)
1422 flags |= EXT3_IMMUTABLE_FL;
1423 if (body->flags & S_NOATIME)
1424 flags |= EXT3_NOATIME_FL;
1426 ptlrpc_req_finished (req);
1428 RETURN(put_user(flags, (int *)arg));
1430 case EXT3_IOC_SETFLAGS: {
1431 struct mdc_op_data op_data;
1434 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1436 if (get_user(flags, (int *)arg))
1443 ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
1445 memset(&attr, 0x0, sizeof(attr));
1446 attr.ia_attr_flags = flags;
1447 attr.ia_valid |= ATTR_ATTR_FLAG;
1449 rc = md_setattr(sbi->ll_lmv_exp, &op_data,
1450 &attr, NULL, 0, NULL, 0, &req);
1452 ptlrpc_req_finished(req);
1453 if (rc != -EPERM && rc != -EACCES)
1454 CERROR("md_setattr fails: rc = %d\n", rc);
1458 ptlrpc_req_finished(req);
1460 oa->o_id = lsm->lsm_object_id;
1461 oa->o_gr = lsm->lsm_object_gr;
1462 oa->o_flags = flags;
1463 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1465 rc = obd_setattr(sbi->ll_lov_exp, oa, lsm, NULL);
1468 if (rc != -EPERM && rc != -EACCES)
1469 CERROR("md_setattr fails: rc = %d\n", rc);
1473 if (flags & EXT3_APPEND_FL)
1474 inode->i_flags |= S_APPEND;
1476 inode->i_flags &= ~S_APPEND;
1477 if (flags & EXT3_IMMUTABLE_FL)
1478 inode->i_flags |= S_IMMUTABLE;
1480 inode->i_flags &= ~S_IMMUTABLE;
1481 if (flags & EXT3_NOATIME_FL)
1482 inode->i_flags |= S_NOATIME;
1484 inode->i_flags &= ~S_NOATIME;
1495 /* this is only called in the case of forced umount. */
1496 void ll_umount_begin(struct super_block *sb)
1498 struct ll_sb_info *sbi = ll_s2sbi(sb);
1499 struct obd_device *obd;
1500 struct obd_ioctl_data ioc_data = { 0 };
1503 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb,
1504 sb->s_count, atomic_read(&sb->s_active));
1506 obd = class_exp2obd(sbi->ll_lmv_exp);
1508 CERROR("Invalid MDC connection handle "LPX64"\n",
1509 sbi->ll_lmv_exp->exp_handle.h_cookie);
1513 obd->obd_no_recov = 1;
1514 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lmv_exp,
1515 sizeof(ioc_data), &ioc_data, NULL);
1517 obd = class_exp2obd(sbi->ll_lov_exp);
1519 CERROR("Invalid LOV connection handle "LPX64"\n",
1520 sbi->ll_lov_exp->exp_handle.h_cookie);
1525 obd->obd_no_recov = 1;
1526 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lov_exp,
1527 sizeof(ioc_data), &ioc_data, NULL);
1530 * really, we'd like to wait until there are no requests outstanding,
1531 * and then continue. For now, we just invalidate the requests,
1532 * schedule, and hope.
1539 int ll_prep_inode(struct obd_export *lov_exp, struct obd_export *lmv_exp,
1540 struct inode **inode, struct ptlrpc_request *req,
1541 int offset, struct super_block *sb)
1543 struct lustre_md md;
1546 rc = mdc_req2lustre_md(lmv_exp, req, offset, lov_exp, &md);
1551 ll_update_inode(*inode, &md);
1554 *inode = ll_iget(sb, id_ino(&md.body->id1), &md);
1555 if (*inode == NULL || is_bad_inode(*inode)) {
1556 /* free the lsm if we allocated one above */
1558 obd_free_memmd(lov_exp, &md.lsm);
1560 obd_free_memmd(lmv_exp,
1561 (struct lov_stripe_md**)&md.mea);
1563 CERROR("new_inode -fatal: rc %d\n", rc);
1570 int ll_get_fid(struct obd_export *exp, struct lustre_id *idp,
1571 char *filename, struct lustre_id *ret)
1573 struct ptlrpc_request *request = NULL;
1574 struct mds_body *body;
1578 valid |= OBD_MD_FID;
1580 rc = md_getattr_lock(exp, idp, filename, strlen(filename) + 1,
1581 valid, 0, &request);
1583 CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
1588 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
1589 LASSERT(body != NULL);
1590 LASSERT_REPSWABBED(request, 0);
1593 ptlrpc_req_finished(request);