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;
132 obd = class_name2obd(lmv);
134 CERROR("MDC %s: not setup or attached\n", lmv);
138 if (proc_lustre_fs_root) {
139 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
142 CERROR("could not register mount in /proc/lustre");
145 err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, 0);
147 CERROR("An MDS (mdc %s) is performing recovery, of which this"
148 " client is not a part. Please wait for recovery to "
149 "complete, abort, or time out.\n", lmv);
152 CERROR("cannot connect to %s: rc = %d\n", lmv, err);
155 sbi->ll_lmv_exp = class_conn2export(&lmv_conn);
157 lustre_init_lmv_desc(sbi);
159 err = obd_statfs(obd, &osfs, jiffies - HZ);
163 if (!osfs.os_bsize) {
164 CERROR("Invalid block size is detected.");
168 sb->s_magic = LL_SUPER_MAGIC;
169 sb->s_blocksize = osfs.os_bsize;
170 sb->s_blocksize_bits = log2(osfs.os_bsize);
171 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
173 devno = get_uuid2int(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid,
174 strlen(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid));
178 obd = class_name2obd(lov);
180 CERROR("OSC %s: not setup or attached\n", lov);
184 err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, 0);
186 CERROR("An OST (osc %s) is performing recovery, of which this"
187 " client is not a part. Please wait for recovery to "
188 "complete, abort, or time out.\n", lov);
191 CERROR("cannot connect to %s: rc = %d\n", lov, err);
194 sbi->ll_lov_exp = class_conn2export(&lov_conn);
196 err = lustre_init_lov_desc(sbi);
198 int mdsize = obd_size_diskmd(sbi->ll_lov_exp, NULL);
199 obd_init_ea_size(sbi->ll_lmv_exp, mdsize,
200 sbi->ll_lov_desc.ld_tgt_count *
201 sizeof(struct llog_cookie));
204 err = md_getstatus(sbi->ll_lmv_exp, &sbi->ll_rootid);
206 CERROR("cannot mds_connect: rc = %d\n", err);
209 CDEBUG(D_SUPER, "rootid "DLID4"\n", OLID4(&sbi->ll_rootid));
211 sb->s_op = &lustre_super_operations;
214 * XXX: move this to after cbd setup? */
215 err = md_getattr(sbi->ll_lmv_exp, &sbi->ll_rootid,
216 OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID,
219 CERROR("md_getattr failed for root: rc = %d\n", err);
223 err = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0,
224 sbi->ll_lov_exp, &md);
226 CERROR("failed to understand root inode md: rc = %d\n", err);
227 ptlrpc_req_finished(request);
231 LASSERT(sbi->ll_rootid.li_stc.u.e3s.l3s_ino != 0);
232 root = ll_iget(sb, sbi->ll_rootid.li_stc.u.e3s.l3s_ino, &md);
234 ptlrpc_req_finished(request);
236 if (root == NULL || is_bad_inode(root)) {
237 CERROR("lustre_lite: bad iget4 for root\n");
238 GOTO(out_root, err = -EBADF);
241 err = ll_close_thread_start(&sbi->ll_lcq);
243 CERROR("cannot start close thread: rc %d\n", err);
247 ll_gns_add_timer(sbi);
249 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x, backing dev
250 info assigned to inode mapping is used for determining maximal
252 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
253 /* bug 2805 - set VM readahead to zero */
254 vm_max_readahead = vm_min_readahead = 0;
257 sb->s_root = d_alloc_root(root);
260 CWARN("Enabling PDIROPS\n");
261 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);
424 OBD_FREE(lmv, strlen(lmv) + 1);
426 OBD_FREE(lov, strlen(lov) + 1);
428 } /* ll_read_super */
430 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
431 struct config_llog_instance *cfg, int allow_recov)
433 struct lustre_cfg lcfg;
434 struct portals_cfg pcfg;
435 char *peer = "MDS_PEER_UUID";
436 struct obd_device *obd;
437 struct lustre_handle lmv_conn = {0, };
438 struct obd_export *exp;
439 char *name = "mdc_dev";
441 struct obd_uuid lmv_uuid;
442 struct llog_ctxt *ctxt;
447 if (lmd_bad_magic(lmd))
450 generate_random_uuid(uuid);
451 class_uuid_unparse(uuid, &lmv_uuid);
453 if (lmd->lmd_local_nid) {
454 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
455 pcfg.pcfg_nal = lmd->lmd_nal;
456 pcfg.pcfg_nid = lmd->lmd_local_nid;
457 err = libcfs_nal_cmd(&pcfg);
462 if (lmd->lmd_nal == SOCKNAL ||
463 lmd->lmd_nal == OPENIBNAL) {
464 PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);
465 pcfg.pcfg_nal = lmd->lmd_nal;
466 pcfg.pcfg_nid = lmd->lmd_server_nid;
467 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
468 pcfg.pcfg_misc = lmd->lmd_port;
469 pcfg.pcfg_size = 8388608;
470 pcfg.pcfg_flags = 0x4; /*share*/
471 err = libcfs_nal_cmd(&pcfg);
476 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
477 lcfg.lcfg_nid = lmd->lmd_server_nid;
478 lcfg.lcfg_inllen1 = strlen(peer) + 1;
479 lcfg.lcfg_inlbuf1 = peer;
480 lcfg.lcfg_nal = lmd->lmd_nal;
481 err = class_process_config(&lcfg);
483 GOTO(out_del_conn, err);
485 LCFG_INIT(lcfg, LCFG_ATTACH, name);
486 lcfg.lcfg_inlbuf1 = "mdc";
487 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
488 lcfg.lcfg_inlbuf2 = lmv_uuid.uuid;
489 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
490 err = class_process_config(&lcfg);
492 GOTO(out_del_uuid, err);
494 LCFG_INIT(lcfg, LCFG_SETUP, name);
495 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
496 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
497 lcfg.lcfg_inlbuf2 = peer;
498 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
499 err = class_process_config(&lcfg);
501 GOTO(out_detach, err);
503 obd = class_name2obd(name);
505 GOTO(out_cleanup, err = -EINVAL);
507 /* Disable initial recovery on this import */
508 err = obd_set_info(obd->obd_self_export,
509 strlen("initial_recov"), "initial_recov",
510 sizeof(allow_recov), &allow_recov);
512 GOTO(out_cleanup, err);
514 err = obd_connect(&lmv_conn, obd, &lmv_uuid, 0);
516 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
517 GOTO(out_cleanup, err);
520 exp = class_conn2export(&lmv_conn);
522 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
523 rc = class_config_process_llog(ctxt, profile, cfg);
525 CERROR("class_config_process_llog failed: rc = %d\n", rc);
527 err = obd_disconnect(exp, 0);
530 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
531 err = class_process_config(&lcfg);
536 LCFG_INIT(lcfg, LCFG_DETACH, name);
537 err = class_process_config(&lcfg);
542 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
543 lcfg.lcfg_inllen1 = strlen(peer) + 1;
544 lcfg.lcfg_inlbuf1 = peer;
545 err = class_process_config(&lcfg);
548 if (lmd->lmd_nal == SOCKNAL ||
549 lmd->lmd_nal == OPENIBNAL) {
550 PCFG_INIT(pcfg, NAL_CMD_DEL_PEER);
551 pcfg.pcfg_nal = lmd->lmd_nal;
552 pcfg.pcfg_nid = lmd->lmd_server_nid;
553 pcfg.pcfg_flags = 1; /* single_share */
554 err = libcfs_nal_cmd(&pcfg);
565 int lustre_fill_super(struct super_block *sb, void *data, int silent)
567 struct lustre_mount_data * lmd = data;
568 char *lov = NULL, *lmv = NULL;
569 struct ll_sb_info *sbi;
573 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
574 if (lmd_bad_magic(lmd))
577 sbi = lustre_init_sbi(sb);
581 sbi->ll_flags |= LL_SBI_READAHEAD;
583 if (lmd->lmd_profile) {
584 struct lustre_profile *lprof;
585 struct config_llog_instance cfg;
588 if (lmd->lmd_mds[0] == '\0') {
589 CERROR("no mds name\n");
590 GOTO(out_free, err = -EINVAL);
593 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
594 if (sbi->ll_lmd == NULL)
595 GOTO(out_free, err = -ENOMEM);
596 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
598 /* generate a string unique to this super, let's try
599 the address of the super itself.*/
600 len = (sizeof(sb) * 2) + 1;
601 OBD_ALLOC(sbi->ll_instance, len);
602 if (sbi->ll_instance == NULL)
603 GOTO(out_free, err = -ENOMEM);
604 sprintf(sbi->ll_instance, "%p", sb);
606 cfg.cfg_instance = sbi->ll_instance;
607 cfg.cfg_uuid = sbi->ll_sb_uuid;
608 cfg.cfg_local_nid = lmd->lmd_local_nid;
609 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
611 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
615 lprof = class_get_profile(lmd->lmd_profile);
617 CERROR("No profile found: %s\n", lmd->lmd_profile);
618 GOTO(out_free, err = -EINVAL);
621 OBD_FREE(lov, strlen(lov) + 1);
622 OBD_ALLOC(lov, strlen(lprof->lp_lov) +
623 strlen(sbi->ll_instance) + 2);
624 sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance);
627 OBD_FREE(lmv, strlen(lmv) + 1);
628 OBD_ALLOC(lmv, strlen(lprof->lp_lmv) +
629 strlen(sbi->ll_instance) + 2);
630 sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance);
635 GOTO(out_free, err = -EINVAL);
640 GOTO(out_free, err = -EINVAL);
643 err = lustre_common_fill_super(sb, lmv, lov);
650 OBD_FREE(lmv, strlen(lmv) + 1);
652 OBD_FREE(lov, strlen(lov) + 1);
658 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
661 if (sbi->ll_instance != NULL) {
662 struct lustre_mount_data *lmd = sbi->ll_lmd;
664 struct config_llog_instance cfg;
666 cfg.cfg_instance = sbi->ll_instance;
667 cfg.cfg_uuid = sbi->ll_sb_uuid;
669 OBD_ALLOC(cln_prof, len);
670 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
672 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
674 CERROR("Unable to process log: %s\n", cln_prof);
675 OBD_FREE(cln_prof, len);
676 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
678 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
683 } /* lustre_fill_super */
685 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
687 struct lustre_cfg lcfg;
688 struct obd_device *obd;
691 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
695 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
696 err = class_process_config(&lcfg);
698 CERROR("cleanup failed: %s\n", obd->obd_name);
702 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
703 err = class_process_config(&lcfg);
705 CERROR("detach failed: %s\n", obd->obd_name);
710 if (sbi->ll_lmd != NULL)
711 class_del_profile(sbi->ll_lmd->lmd_profile);
714 void lustre_put_super(struct super_block *sb)
716 struct obd_device *obd;
717 struct ll_sb_info *sbi = ll_s2sbi(sb);
718 int force_umount = 0;
721 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
722 obd = class_exp2obd(sbi->ll_lmv_exp);
724 force_umount = obd->obd_no_recov;
727 lustre_common_put_super(sb);
728 if (sbi->ll_lmd != NULL) {
730 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
732 struct config_llog_instance cfg;
735 CERROR("force umount, doing manual cleanup\n");
736 lustre_manual_cleanup(sbi);
740 cfg.cfg_instance = sbi->ll_instance;
741 cfg.cfg_uuid = sbi->ll_sb_uuid;
743 OBD_ALLOC(cln_prof, len);
744 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
746 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
748 CERROR("Unable to process log: %s, doing manual cleanup"
750 lustre_manual_cleanup(sbi);
753 OBD_FREE(cln_prof, len);
755 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
756 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
762 } /* lustre_put_super */
764 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
766 struct obd_export *lmv_exp = sbi->ll_lmv_exp;
767 struct lustre_mount_data *lmd = sbi->ll_lmd;
768 struct llog_ctxt *ctxt;
769 struct config_llog_instance cfg;
770 char *profile = lmd->lmd_profile, *name = NULL;
771 int rc, namelen = 0, version;
777 CERROR("Client not mounted with zero-conf; cannot process "
782 rc = ldlm_cli_cancel_unused(lmv_exp->exp_obd->obd_namespace, NULL,
783 LDLM_FL_CONFIG_CHANGE, NULL);
785 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
787 rc = obd_cancel_unused(sbi->ll_lov_exp, NULL, LDLM_FL_CONFIG_CHANGE,
790 CWARN("obd_cancel_unused(lov): %d\n", rc);
792 cfg.cfg_instance = sbi->ll_instance;
793 cfg.cfg_uuid = sbi->ll_sb_uuid;
794 cfg.cfg_local_nid = lmd->lmd_local_nid;
796 namelen = strlen(profile) + 20; /* -clean-######### */
797 OBD_ALLOC(name, namelen);
802 version = sbi->ll_config_version - 1;
803 sprintf(name, "%s-clean-%d", profile, version);
805 version = sbi->ll_config_version + 1;
806 sprintf(name, "%s-%d", profile, version);
809 CWARN("Applying configuration log %s\n", name);
811 ctxt = llog_get_context(&lmv_exp->exp_obd->obd_llogs,
812 LLOG_CONFIG_REPL_CTXT);
813 rc = class_config_process_llog(ctxt, name, &cfg);
815 sbi->ll_config_version = version;
816 CWARN("Finished applying configuration log %s: %d\n", name, rc);
818 if (rc == 0 && clean == 0) {
819 struct lov_desc desc;
821 valsize = sizeof(desc);
822 rc = obd_get_info(sbi->ll_lov_exp, strlen("lovdesc") + 1,
823 "lovdesc", &valsize, &desc);
825 rc = obd_init_ea_size(lmv_exp,
826 obd_size_diskmd(sbi->ll_lov_exp, NULL),
828 sizeof(struct llog_cookie)));
830 OBD_FREE(name, namelen);
834 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
836 struct inode *inode = NULL;
837 l_lock(&lock->l_resource->lr_namespace->ns_lock);
838 if (lock->l_ast_data) {
839 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
840 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
841 inode = igrab(lock->l_ast_data);
843 CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
844 lock->l_ast_data, lli->lli_inode_magic);
847 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
851 int null_if_equal(struct ldlm_lock *lock, void *data)
853 if (data == lock->l_ast_data) {
854 lock->l_ast_data = NULL;
856 if (lock->l_req_mode != lock->l_granted_mode)
857 LDLM_ERROR(lock,"clearing inode with ungranted lock\n");
860 return LDLM_ITER_CONTINUE;
863 void ll_clear_inode(struct inode *inode)
866 struct ll_inode_info *lli = ll_i2info(inode);
867 struct ll_sb_info *sbi = ll_i2sbi(inode);
870 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
871 inode->i_generation, inode);
873 lli->lli_inode_magic = LLI_INODE_DEAD;
874 ll_inode2id(&id, inode);
876 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
877 md_change_cbdata(sbi->ll_lmv_exp, &id, null_if_equal, inode);
880 obd_change_cbdata(sbi->ll_lov_exp, lli->lli_smd,
881 null_if_equal, inode);
884 obd_free_memmd(sbi->ll_lov_exp, &lli->lli_smd);
889 obd_free_memmd(sbi->ll_lmv_exp,
890 (struct lov_stripe_md **) &lli->lli_mea);
894 if (lli->lli_symlink_name) {
895 OBD_FREE(lli->lli_symlink_name,
896 strlen(lli->lli_symlink_name) + 1);
897 lli->lli_symlink_name = NULL;
903 /* If this inode has objects allocated to it (lsm != NULL), then the OST
904 * object(s) determine the file size and mtime. Otherwise, the MDS will
905 * keep these values until such a time that objects are allocated for it.
906 * We do the MDS operations first, as it is checking permissions for us.
907 * We don't to the MDS RPC if there is nothing that we want to store there,
908 * otherwise there is no harm in updating mtime/atime on the MDS if we are
909 * going to do an RPC anyways.
911 * If we are doing a truncate, we will send the mtime and ctime updates
912 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
913 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
916 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
918 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
919 struct ll_sb_info *sbi = ll_i2sbi(inode);
920 struct ptlrpc_request *request = NULL;
921 struct mdc_op_data op_data;
922 int ia_valid = attr->ia_valid;
926 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
927 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
929 if (ia_valid & ATTR_SIZE) {
930 if (attr->ia_size > ll_file_maxbytes(inode)) {
931 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
932 attr->ia_size, ll_file_maxbytes(inode));
936 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
939 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
940 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
941 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
945 /* We mark all of the fields "set" so MDS/OST does not re-set them */
946 if (attr->ia_valid & ATTR_CTIME) {
947 attr->ia_ctime = CURRENT_TIME;
948 attr->ia_valid |= ATTR_CTIME_SET;
950 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
951 attr->ia_atime = CURRENT_TIME;
952 attr->ia_valid |= ATTR_ATIME_SET;
954 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
955 attr->ia_mtime = CURRENT_TIME;
956 attr->ia_valid |= ATTR_MTIME_SET;
959 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
960 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
961 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
962 LTIME_S(CURRENT_TIME));
964 attr->ia_valid &= ~ATTR_SIZE;
966 /* If only OST attributes being set on objects, don't do MDS RPC.
967 * In that case, we need to check permissions and update the local
968 * inode ourselves so we can call obdo_from_inode() always. */
969 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
971 ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
973 rc = md_setattr(sbi->ll_lmv_exp, &op_data,
974 attr, NULL, 0, NULL, 0, &request);
976 ptlrpc_req_finished(request);
977 if (rc != -EPERM && rc != -EACCES)
978 CERROR("md_setattr fails: rc = %d\n", rc);
982 rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0,
983 sbi->ll_lov_exp, &md);
985 ptlrpc_req_finished(request);
989 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
990 * but needed to set timestamps backwards on utime. */
991 inode_setattr(inode, attr);
992 ll_update_inode(inode, &md);
993 ptlrpc_req_finished(request);
995 if (!lsm || !S_ISREG(inode->i_mode)) {
996 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
1000 /* The OST doesn't check permissions, but the alternative is
1001 * a gratuitous RPC to the MDS. We already rely on the client
1002 * to do read/write/truncate permission checks, so is mtime OK?
1004 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
1005 /* from sys_utime() */
1006 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
1007 if (current->fsuid != inode->i_uid &&
1008 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1011 /* from inode_change_ok() */
1012 if (current->fsuid != inode->i_uid &&
1013 !capable(CAP_FOWNER))
1018 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1019 inode_setattr(inode, attr);
1022 /* We really need to get our PW lock before we change inode->i_size.
1023 * If we don't we can race with other i_size updaters on our node, like
1024 * ll_file_read. We can also race with i_size propogation to other
1025 * nodes through dirtying and writeback of final cached pages. This
1026 * last one is especially bad for racing o_append users on other
1028 if (ia_valid & ATTR_SIZE) {
1029 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1031 struct lustre_handle lockh = { 0 };
1032 int err, ast_flags = 0;
1033 /* XXX when we fix the AST intents to pass the discard-range
1034 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1036 if (attr->ia_size == 0)
1037 ast_flags = LDLM_AST_DISCARD_DATA;
1039 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1040 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1042 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1043 ast_flags, &ll_i2sbi(inode)->ll_seek_stime);
1044 down(&inode->i_sem);
1048 rc = vmtruncate(inode, attr->ia_size);
1050 /* We need to drop the semaphore here, because this unlock may
1051 * result in a cancellation, which will need the i_sem */
1053 /* unlock now as we don't mind others file lockers racing with
1054 * the mds updates below? */
1055 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1056 down(&inode->i_sem);
1058 CERROR("ll_extent_unlock failed: %d\n", err);
1062 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1065 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1066 inode->i_ino, LTIME_S(attr->ia_mtime));
1067 oa.o_id = lsm->lsm_object_id;
1068 oa.o_gr = lsm->lsm_object_gr;
1069 oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1070 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1071 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1072 rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL);
1074 CERROR("obd_setattr fails: rc=%d\n", rc);
1079 int ll_setattr(struct dentry *de, struct iattr *attr)
1081 LBUG(); /* code is unused, but leave this in case of VFS changes */
1085 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1086 unsigned long max_age)
1088 struct ll_sb_info *sbi = ll_s2sbi(sb);
1089 struct obd_statfs obd_osfs;
1093 rc = obd_statfs(class_exp2obd(sbi->ll_lmv_exp), osfs, max_age);
1095 CERROR("mdc_statfs fails: rc = %d\n", rc);
1099 osfs->os_type = sb->s_magic;
1101 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1102 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1104 rc = obd_statfs(class_exp2obd(sbi->ll_lov_exp), &obd_osfs, max_age);
1106 CERROR("obd_statfs fails: rc = %d\n", rc);
1110 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1111 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1114 osfs->os_blocks = obd_osfs.os_blocks;
1115 osfs->os_bfree = obd_osfs.os_bfree;
1116 osfs->os_bavail = obd_osfs.os_bavail;
1118 /* If we don't have as many objects free on the OST as inodes
1119 * on the MDS, we reduce the total number of inodes to
1120 * compensate, so that the "inodes in use" number is correct.
1122 if (obd_osfs.os_ffree < osfs->os_ffree) {
1123 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1125 osfs->os_ffree = obd_osfs.os_ffree;
1131 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1133 struct obd_statfs osfs;
1136 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p\n", sb);
1137 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1139 /* For now we will always get up-to-date statfs values, but in the
1140 * future we may allow some amount of caching on the client (e.g.
1141 * from QOS or lprocfs updates). */
1142 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1146 statfs_unpack(sfs, &osfs);
1148 if (sizeof(sfs->f_blocks) == 4) {
1149 while (osfs.os_blocks > ~0UL) {
1152 osfs.os_blocks >>= 1;
1153 osfs.os_bfree >>= 1;
1154 osfs.os_bavail >>= 1;
1158 sfs->f_blocks = osfs.os_blocks;
1159 sfs->f_bfree = osfs.os_bfree;
1160 sfs->f_bavail = osfs.os_bavail;
1165 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1167 struct ll_sb_info *sbi = ll_s2sbi(inode->i_sb);
1168 struct ll_inode_info *lli = ll_i2info(inode);
1169 struct lov_stripe_md *lsm = md->lsm;
1170 struct mds_body *body = md->body;
1171 struct mea *mea = md->mea;
1174 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1175 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1177 LASSERT(lsm->lsm_object_gr > 0);
1178 if (lli->lli_smd == NULL) {
1180 lli->lli_maxbytes = lsm->lsm_maxbytes;
1181 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1182 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1185 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1186 CERROR("lsm mismatch for inode %ld\n",
1188 CERROR("lli_smd:\n");
1189 dump_lsm(D_ERROR, lli->lli_smd);
1191 dump_lsm(D_ERROR, lsm);
1194 /* XXX FIXME -- We should decide on a safer (atomic) and
1195 * more elegant way to update the lsm */
1196 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1197 lli->lli_smd->lsm_oinfo[i].loi_id =
1198 lsm->lsm_oinfo[i].loi_id;
1199 lli->lli_smd->lsm_oinfo[i].loi_gr =
1200 lsm->lsm_oinfo[i].loi_gr;
1201 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1202 lsm->lsm_oinfo[i].loi_ost_idx;
1203 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1204 lsm->lsm_oinfo[i].loi_ost_gen;
1207 /* bug 2844 - limit i_blksize for broken user-space apps */
1208 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1209 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1210 if (lli->lli_smd != lsm)
1211 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1215 if (lli->lli_mea == NULL) {
1218 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1219 CERROR("mea mismatch for inode %lu\n",
1224 if (lli->lli_mea != mea)
1225 obd_free_memmd(ll_i2lmvexp(inode),
1226 (struct lov_stripe_md **) &mea);
1230 * updating inode lustre id. We try optimize things a little bit here,
1231 * thus do not do it all the time.
1233 if (body->valid & OBD_MD_FID) {
1234 LASSERT(id_fid(&body->id1) != 0);
1235 id_assign_fid(&lli->lli_id, &body->id1);
1238 if ((body->valid & OBD_MD_FLID) || (body->valid & OBD_MD_FLGENER))
1239 id_assign_stc(&lli->lli_id, &body->id1);
1241 if (body->valid & OBD_MD_FLID)
1242 inode->i_ino = id_ino(&body->id1);
1243 if (body->valid & OBD_MD_FLGENER)
1244 inode->i_generation = id_gen(&body->id1);
1245 if (body->valid & OBD_MD_FLATIME)
1246 LTIME_S(inode->i_atime) = body->atime;
1247 if (body->valid & OBD_MD_FLMTIME &&
1248 body->mtime > LTIME_S(inode->i_mtime)) {
1249 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1250 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1251 LTIME_S(inode->i_mtime) = body->mtime;
1253 if (body->valid & OBD_MD_FLCTIME &&
1254 body->ctime > LTIME_S(inode->i_ctime))
1255 LTIME_S(inode->i_ctime) = body->ctime;
1256 if (body->valid & OBD_MD_FLMODE) {
1257 inode->i_mode = (inode->i_mode & S_IFMT) |
1258 (body->mode & ~S_IFMT);
1260 if (body->valid & OBD_MD_FLTYPE) {
1261 inode->i_mode = (inode->i_mode & ~S_IFMT) |
1262 (body->mode & S_IFMT);
1264 if (body->valid & OBD_MD_FLUID)
1265 inode->i_uid = body->uid;
1266 if (body->valid & OBD_MD_FLGID)
1267 inode->i_gid = body->gid;
1268 if (body->valid & OBD_MD_FLFLAGS)
1269 inode->i_flags = body->flags;
1270 if (body->valid & OBD_MD_FLNLINK)
1271 inode->i_nlink = body->nlink;
1272 if (body->valid & OBD_MD_FLRDEV)
1273 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1274 inode->i_rdev = body->rdev;
1276 inode->i_rdev = old_decode_dev(body->rdev);
1278 if (body->valid & OBD_MD_FLSIZE)
1279 inode->i_size = body->size;
1280 if (body->valid & OBD_MD_FLBLOCKS)
1281 inode->i_blocks = body->blocks;
1283 if (body->valid & OBD_MD_FLSIZE)
1284 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1286 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1287 inode->i_dev = (kdev_t)id_group(&lli->lli_id);
1289 LASSERT(!sbi->ll_lmv_desc.ld_tgt_count ||
1290 id_group(&lli->lli_id) < sbi->ll_lmv_desc.ld_tgt_count);
1293 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1294 static struct backing_dev_info ll_backing_dev_info = {
1295 .ra_pages = 0, /* No readahead */
1296 .memory_backed = 0, /* Does contribute to dirty memory */
1300 void ll_read_inode2(struct inode *inode, void *opaque)
1302 struct lustre_md *md = opaque;
1303 struct ll_inode_info *lli = ll_i2info(inode);
1306 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1307 inode->i_generation, inode);
1311 LASSERT(!lli->lli_smd);
1313 /* Core attributes from the MDS first. This is a new inode, and
1314 * the VFS doesn't zero times in the core inode so we have to do
1315 * it ourselves. They will be overwritten by either MDS or OST
1316 * attributes - we just need to make sure they aren't newer. */
1317 LTIME_S(inode->i_mtime) = 0;
1318 LTIME_S(inode->i_atime) = 0;
1319 LTIME_S(inode->i_ctime) = 0;
1322 ll_update_inode(inode, md);
1324 /* OIDEBUG(inode); */
1326 if (S_ISREG(inode->i_mode)) {
1327 inode->i_op = &ll_file_inode_operations;
1328 inode->i_fop = &ll_file_operations;
1329 inode->i_mapping->a_ops = &ll_aops;
1331 } else if (S_ISDIR(inode->i_mode)) {
1332 inode->i_op = &ll_dir_inode_operations;
1333 inode->i_fop = &ll_dir_operations;
1334 inode->i_mapping->a_ops = &ll_dir_aops;
1336 } else if (S_ISLNK(inode->i_mode)) {
1337 inode->i_op = &ll_fast_symlink_inode_operations;
1340 inode->i_op = &ll_special_inode_operations;
1342 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1343 init_special_inode(inode, inode->i_mode,
1344 kdev_t_to_nr(inode->i_rdev));
1346 /* initializing backing dev info. */
1347 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1349 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1351 lli->ll_save_ifop = inode->i_fop;
1353 if (S_ISCHR(inode->i_mode))
1354 inode->i_fop = &ll_special_chr_inode_fops;
1355 else if (S_ISBLK(inode->i_mode))
1356 inode->i_fop = &ll_special_blk_inode_fops;
1357 else if (S_ISFIFO(inode->i_mode))
1358 inode->i_fop = &ll_special_fifo_inode_fops;
1359 else if (S_ISSOCK(inode->i_mode))
1360 inode->i_fop = &ll_special_sock_inode_fops;
1362 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1365 if (lli->ll_save_ifop->owner) {
1366 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1367 lli->ll_save_ifop->owner);
1373 void ll_delete_inode(struct inode *inode)
1376 struct lustre_id id;
1377 struct ll_sb_info *sbi = ll_i2sbi(inode);
1380 ll_inode2id(&id, inode);
1382 rc = md_delete_object(sbi->ll_lmv_exp, &id);
1384 CERROR("md_delete_object() failed, error %d.\n",
1392 int ll_iocontrol(struct inode *inode, struct file *file,
1393 unsigned int cmd, unsigned long arg)
1395 struct ll_sb_info *sbi = ll_i2sbi(inode);
1396 struct ptlrpc_request *req = NULL;
1401 case EXT3_IOC_GETFLAGS: {
1402 struct lustre_id id;
1403 unsigned long valid = OBD_MD_FLFLAGS;
1404 struct mds_body *body;
1406 ll_inode2id(&id, inode);
1407 rc = md_getattr(sbi->ll_lmv_exp, &id, valid, 0, &req);
1409 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1413 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1415 if (body->flags & S_APPEND)
1416 flags |= EXT3_APPEND_FL;
1417 if (body->flags & S_IMMUTABLE)
1418 flags |= EXT3_IMMUTABLE_FL;
1419 if (body->flags & S_NOATIME)
1420 flags |= EXT3_NOATIME_FL;
1422 ptlrpc_req_finished (req);
1424 RETURN(put_user(flags, (int *)arg));
1426 case EXT3_IOC_SETFLAGS: {
1427 struct mdc_op_data op_data;
1430 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1432 if (get_user(flags, (int *)arg))
1439 ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
1441 memset(&attr, 0x0, sizeof(attr));
1442 attr.ia_attr_flags = flags;
1443 attr.ia_valid |= ATTR_ATTR_FLAG;
1445 rc = md_setattr(sbi->ll_lmv_exp, &op_data,
1446 &attr, NULL, 0, NULL, 0, &req);
1448 ptlrpc_req_finished(req);
1449 if (rc != -EPERM && rc != -EACCES)
1450 CERROR("md_setattr fails: rc = %d\n", rc);
1454 ptlrpc_req_finished(req);
1456 oa->o_id = lsm->lsm_object_id;
1457 oa->o_gr = lsm->lsm_object_gr;
1458 oa->o_flags = flags;
1459 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1461 rc = obd_setattr(sbi->ll_lov_exp, oa, lsm, NULL);
1464 if (rc != -EPERM && rc != -EACCES)
1465 CERROR("md_setattr fails: rc = %d\n", rc);
1469 if (flags & EXT3_APPEND_FL)
1470 inode->i_flags |= S_APPEND;
1472 inode->i_flags &= ~S_APPEND;
1473 if (flags & EXT3_IMMUTABLE_FL)
1474 inode->i_flags |= S_IMMUTABLE;
1476 inode->i_flags &= ~S_IMMUTABLE;
1477 if (flags & EXT3_NOATIME_FL)
1478 inode->i_flags |= S_NOATIME;
1480 inode->i_flags &= ~S_NOATIME;
1491 /* this is only called in the case of forced umount. */
1492 void ll_umount_begin(struct super_block *sb)
1494 struct ll_sb_info *sbi = ll_s2sbi(sb);
1495 struct obd_device *obd;
1496 struct obd_ioctl_data ioc_data = { 0 };
1499 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb,
1500 sb->s_count, atomic_read(&sb->s_active));
1502 obd = class_exp2obd(sbi->ll_lmv_exp);
1504 CERROR("Invalid MDC connection handle "LPX64"\n",
1505 sbi->ll_lmv_exp->exp_handle.h_cookie);
1509 obd->obd_no_recov = 1;
1510 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lmv_exp,
1511 sizeof(ioc_data), &ioc_data, NULL);
1513 obd = class_exp2obd(sbi->ll_lov_exp);
1515 CERROR("Invalid LOV connection handle "LPX64"\n",
1516 sbi->ll_lov_exp->exp_handle.h_cookie);
1521 obd->obd_no_recov = 1;
1522 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lov_exp,
1523 sizeof(ioc_data), &ioc_data, NULL);
1526 * really, we'd like to wait until there are no requests outstanding,
1527 * and then continue. For now, we just invalidate the requests,
1528 * schedule, and hope.
1535 int ll_prep_inode(struct obd_export *lov_exp, struct obd_export *lmv_exp,
1536 struct inode **inode, struct ptlrpc_request *req,
1537 int offset, struct super_block *sb)
1539 struct lustre_md md;
1542 rc = mdc_req2lustre_md(lmv_exp, req, offset, lov_exp, &md);
1547 ll_update_inode(*inode, &md);
1550 *inode = ll_iget(sb, id_ino(&md.body->id1), &md);
1551 if (*inode == NULL || is_bad_inode(*inode)) {
1552 /* free the lsm if we allocated one above */
1554 obd_free_memmd(lov_exp, &md.lsm);
1556 obd_free_memmd(lmv_exp,
1557 (struct lov_stripe_md**)&md.mea);
1559 CERROR("new_inode -fatal: rc %d\n", rc);