1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre Light Super operations
6 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DEBUG_SUBSYSTEM S_LLITE
26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/random.h>
29 #include <linux/version.h>
31 #include <linux/lustre_lite.h>
32 #include <linux/lustre_ha.h>
33 #include <linux/lustre_dlm.h>
34 #include <linux/lprocfs_status.h>
35 #include <linux/lustre_snap.h>
36 #include "llite_internal.h"
38 kmem_cache_t *ll_file_data_slab;
40 extern struct address_space_operations ll_aops;
41 extern struct address_space_operations ll_dir_aops;
44 #define log2(n) ffz(~(n))
47 struct ll_sb_info *lustre_init_sbi(struct super_block *sb)
49 struct ll_sb_info *sbi = NULL;
53 OBD_ALLOC(sbi, sizeof(*sbi));
57 spin_lock_init(&sbi->ll_lock);
58 INIT_LIST_HEAD(&sbi->ll_pglist);
59 sbi->ll_pglist_gen = 0;
60 sbi->ll_max_read_ahead_pages = SBI_DEFAULT_RA_MAX;
61 INIT_LIST_HEAD(&sbi->ll_conn_chain);
62 INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
63 INIT_LIST_HEAD(&sbi->ll_mnt_list);
64 sema_init(&sbi->ll_gns_sem, 1);
65 init_completion(&sbi->ll_gns_completion);
66 sbi->ll_gns_state = LL_GNS_STATE_IDLE;
67 sbi->ll_gns_timer.data = (unsigned long)sbi;
68 sbi->ll_gns_timer.function = ll_gns_timer_callback;
69 init_timer(&sbi->ll_gns_timer);
70 INIT_LIST_HEAD(&sbi->ll_gns_sbi_head);
74 generate_random_uuid(uuid);
75 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
79 void lustre_free_sbi(struct super_block *sb)
81 struct ll_sb_info *sbi = ll_s2sbi(sb);
85 list_del(&sbi->ll_gns_sbi_head);
86 del_timer(&sbi->ll_gns_timer);
87 OBD_FREE(sbi, sizeof(*sbi));
93 int lustre_init_ea_size(struct ll_sb_info *sbi)
98 /* OSC may have larger ea size */
99 valsize = sizeof(desc);
100 rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc",
103 obd_init_ea_size(sbi->ll_mdc_exp,
104 obd_size_diskmd(sbi->ll_osc_exp, NULL),
105 desc.ld_tgt_count*sizeof(struct llog_cookie));
107 /* declare ourself as real client. not connection
109 * FIXME: remove fake valsize, mdsize --bzzz */
110 rc = obd_set_info(sbi->ll_mdc_exp, strlen("client"),
111 "client", valsize, &desc);
116 int lustre_set_clone_info(struct super_block *sb, int clone_index)
118 struct ll_sb_info *sbi = ll_s2sbi(sb);
122 CDEBUG(D_INFO, "set clone index %d\n", clone_index);
126 if (sbi->ll_mdc_exp) {
127 struct obd_import *climp = class_exp2cliimp(sbi->ll_mdc_exp);
128 struct client_obd *cl_obd = &climp->imp_obd->u.cli;
130 OBD_ALLOC(cl_obd->cl_clone_info, sizeof(struct clonefs_info));
131 if (!cl_obd->cl_clone_info)
133 SET_CLONE_INDEX(cl_obd->cl_clone_info, clone_index);
134 SET_CLONE_FLAGS(cl_obd->cl_clone_info, SM_CLONE_FS);
137 if (sbi->ll_osc_exp) {
138 struct obd_import *climp = class_exp2cliimp(sbi->ll_osc_exp);
139 struct client_obd *cl_obd = &climp->imp_obd->u.cli;
141 OBD_ALLOC(cl_obd->cl_clone_info, sizeof(struct clonefs_info));
142 if (!cl_obd->cl_clone_info)
144 SET_CLONE_INDEX(cl_obd->cl_clone_info, clone_index);
145 SET_CLONE_FLAGS(cl_obd->cl_clone_info, SM_CLONE_FS);
150 int lustre_cleanup_clone_info(struct super_block *sb)
152 struct ll_sb_info *sbi = ll_s2sbi(sb);
156 if (sbi->ll_mdc_exp) {
157 struct obd_import *climp = class_exp2cliimp(sbi->ll_mdc_exp);
158 struct client_obd *cl_obd = &climp->imp_obd->u.cli;
160 if (!cl_obd->cl_clone_info)
162 CDEBUG(D_INFO, "clean clone info %p\n", cl_obd->cl_clone_info);
163 OBD_FREE(cl_obd->cl_clone_info, sizeof(struct clonefs_info));
166 if (sbi->ll_osc_exp) {
167 struct obd_import *climp = class_exp2cliimp(sbi->ll_osc_exp);
168 struct client_obd *cl_obd = &climp->imp_obd->u.cli;
170 if (!cl_obd->cl_clone_info)
172 CDEBUG(D_INFO, "clean clone info %p\n", cl_obd->cl_clone_info);
173 OBD_FREE(cl_obd->cl_clone_info, sizeof(struct clonefs_info));
180 int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
182 struct inode *root = 0;
183 struct ll_sb_info *sbi = ll_s2sbi(sb);
184 struct obd_device *obd;
185 struct ll_fid rootfid;
186 struct obd_statfs osfs;
187 struct ptlrpc_request *request = NULL;
188 struct lustre_handle osc_conn = {0, };
189 struct lustre_handle mdc_conn = {0, };
194 obd = class_name2obd(mdc);
196 CERROR("MDC %s: not setup or attached\n", mdc);
200 if (proc_lustre_fs_root) {
201 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
204 CERROR("could not register mount in /proc/lustre");
207 err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid);
209 CERROR("An MDS (mdc %s) is performing recovery, of which this"
210 " client is not a part. Please wait for recovery to "
211 "complete, abort, or time out.\n", mdc);
214 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
217 sbi->ll_mdc_exp = class_conn2export(&mdc_conn);
219 err = obd_statfs(obd, &osfs, jiffies - HZ);
223 LASSERT(osfs.os_bsize);
224 sb->s_blocksize = osfs.os_bsize;
225 sb->s_blocksize_bits = log2(osfs.os_bsize);
226 sb->s_magic = LL_SUPER_MAGIC;
227 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
229 devno = get_uuid2int(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid,
230 strlen(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid));
234 obd = class_name2obd(osc);
236 CERROR("OSC %s: not setup or attached\n", osc);
240 err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid);
242 CERROR("An OST (osc %s) is performing recovery, of which this"
243 " client is not a part. Please wait for recovery to "
244 "complete, abort, or time out.\n", osc);
247 CERROR("cannot connect to %s: rc = %d\n", osc, err);
250 sbi->ll_osc_exp = class_conn2export(&osc_conn);
252 lustre_init_ea_size(sbi);
254 err = md_getstatus(sbi->ll_mdc_exp, &rootfid);
256 CERROR("cannot mds_connect: rc = %d\n", err);
259 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
260 sbi->ll_rootino = rootfid.id;
262 sb->s_op = &lustre_super_operations;
265 * XXX: move this to after cbd setup? */
266 err = md_getattr(sbi->ll_mdc_exp, &rootfid,
267 OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS, 0, &request);
269 CERROR("md_getattr failed for root: rc = %d\n", err);
273 err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0,
274 sbi->ll_osc_exp, &md);
276 CERROR("failed to understand root inode md: rc = %d\n",err);
277 ptlrpc_req_finished (request);
281 LASSERT(sbi->ll_rootino != 0);
282 root = ll_iget(sb, sbi->ll_rootino, &md);
284 ptlrpc_req_finished(request);
286 if (root == NULL || is_bad_inode(root)) {
287 /* XXX might need iput() for bad inode */
288 CERROR("lustre_lite: bad iget4 for root\n");
289 GOTO(out_root, err = -EBADF);
292 err = ll_close_thread_start(&sbi->ll_lcq);
294 CERROR("cannot start close thread: rc %d\n", err);
298 ll_gns_add_timer(sbi);
300 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x,
301 backing dev info assigned to inode mapping is used for
302 determining maximal readahead. */
303 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
304 /* bug 2805 - set VM readahead to zero */
305 vm_max_readahead = vm_min_readahead = 0;
308 sb->s_root = d_alloc_root(root);
311 CWARN("Enabling PDIROPS\n");
312 sb->s_flags |= S_PDIROPS;
321 obd_disconnect(sbi->ll_osc_exp, 0);
323 obd_disconnect(sbi->ll_mdc_exp, 0);
325 lprocfs_unregister_mountpoint(sbi);
329 void lustre_common_put_super(struct super_block *sb)
331 struct ll_sb_info *sbi = ll_s2sbi(sb);
332 struct hlist_node *tmp, *next;
335 ll_gns_del_timer(sbi);
337 ll_close_thread_shutdown(sbi->ll_lcq);
339 list_del(&sbi->ll_conn_chain);
340 obd_disconnect(sbi->ll_osc_exp, 0);
342 lprocfs_unregister_mountpoint(sbi);
343 if (sbi->ll_proc_root) {
344 lprocfs_remove(sbi->ll_proc_root);
345 sbi->ll_proc_root = NULL;
348 obd_disconnect(sbi->ll_mdc_exp, 0);
350 // We do this to get rid of orphaned dentries. That is not really trw.
351 spin_lock(&dcache_lock);
352 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
353 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
354 CWARN("orphan dentry %*s (%p) at unmount\n",
355 dentry->d_name.len, dentry->d_name.name, dentry);
356 shrink_dcache_parent(dentry);
358 spin_unlock(&dcache_lock);
363 char *ll_read_opt(const char *opt, char *data)
369 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
370 if (strncmp(opt, data, strlen(opt)))
372 if ((value = strchr(data, '=')) == NULL)
376 OBD_ALLOC(retval, strlen(value) + 1);
378 CERROR("out of memory!\n");
382 memcpy(retval, value, strlen(value)+1);
383 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
387 int ll_set_opt(const char *opt, char *data, int fl)
391 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
392 if (strncmp(opt, data, strlen(opt)))
398 void ll_options(char *options, char **ost, char **mdc, int *flags,
402 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
403 char *opt_ptr = options;
412 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
413 for (this_char = strtok (options, ",");
415 this_char = strtok (NULL, ",")) {
417 while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
419 CDEBUG(D_SUPER, "this_char %s\n", this_char);
420 if (!*ost && (*ost = ll_read_opt("osc", this_char)))
422 if (!*mdc && (*mdc = ll_read_opt("mdc", this_char)))
424 if (!*clone_opts && (*clone_opts = ll_read_opt("clone",
427 if (!(*flags & LL_SBI_NOLCK) &&
428 ((*flags) = (*flags) |
429 ll_set_opt("nolock", this_char,
437 void ll_lli_init(struct ll_inode_info *lli)
439 sema_init(&lli->lli_open_sem, 1);
441 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
442 spin_lock_init(&lli->lli_lock);
443 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
446 int ll_fill_super(struct super_block *sb, void *data, int silent)
448 struct ll_sb_info *sbi;
451 char *clone_opts = NULL;
455 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
457 sbi = lustre_init_sbi(sb);
461 sbi->ll_flags |= LL_SBI_READAHEAD;
462 ll_options(data, &osc, &mdc, &sbi->ll_flags, &clone_opts);
466 GOTO(out, err = -EINVAL);
471 GOTO(out, err = -EINVAL);
474 err = lustre_common_fill_super(sb, mdc, osc);
480 /*set clone info to the super block*/
481 clone_index = simple_strtoul(clone_opts, &endp, 0);
482 err = lustre_set_clone_info(sb, clone_index);
490 OBD_FREE(mdc, strlen(mdc) + 1);
492 OBD_FREE(osc, strlen(osc) + 1);
494 OBD_FREE(clone_opts, strlen(clone_opts) + 1);
497 } /* ll_read_super */
499 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
500 struct config_llog_instance *cfg, int allow_recov)
502 struct lustre_cfg lcfg;
503 struct portals_cfg pcfg;
504 char * peer = "MDS_PEER_UUID";
505 struct obd_device *obd;
506 struct lustre_handle mdc_conn = {0, };
507 struct obd_export *exp;
508 char * name = "mdc_dev";
510 struct obd_uuid mdc_uuid;
511 struct llog_ctxt *ctxt;
516 if (lmd_bad_magic(lmd))
519 generate_random_uuid(uuid);
520 class_uuid_unparse(uuid, &mdc_uuid);
522 if (lmd->lmd_local_nid) {
523 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
524 pcfg.pcfg_nal = lmd->lmd_nal;
525 pcfg.pcfg_nid = lmd->lmd_local_nid;
526 err = libcfs_nal_cmd(&pcfg);
531 if (lmd->lmd_nal == SOCKNAL) {
532 PCFG_INIT(pcfg, NAL_CMD_ADD_AUTOCONN);
533 pcfg.pcfg_nal = lmd->lmd_nal;
534 pcfg.pcfg_nid = lmd->lmd_server_nid;
535 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
536 pcfg.pcfg_misc = lmd->lmd_port;
537 pcfg.pcfg_size = 8388608;
538 pcfg.pcfg_flags = 0x4; /*share*/
539 err = libcfs_nal_cmd(&pcfg);
544 LCFG_INIT(lcfg, LCFG_ADD_UUID, name);
545 lcfg.lcfg_nid = lmd->lmd_server_nid;
546 lcfg.lcfg_inllen1 = strlen(peer) + 1;
547 lcfg.lcfg_inlbuf1 = peer;
548 lcfg.lcfg_nal = lmd->lmd_nal;
549 err = class_process_config(&lcfg);
551 GOTO(out_del_conn, err);
553 LCFG_INIT(lcfg, LCFG_ATTACH, name);
554 lcfg.lcfg_inlbuf1 = "mdc";
555 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
556 lcfg.lcfg_inlbuf2 = mdc_uuid.uuid;
557 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
558 err = class_process_config(&lcfg);
560 GOTO(out_del_uuid, err);
562 LCFG_INIT(lcfg, LCFG_SETUP, name);
563 lcfg.lcfg_inlbuf1 = lmd->lmd_mds;
564 lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1;
565 lcfg.lcfg_inlbuf2 = peer;
566 lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1;
567 err = class_process_config(&lcfg);
569 GOTO(out_detach, err);
571 obd = class_name2obd(name);
573 GOTO(out_cleanup, err = -EINVAL);
575 /* Disable initial recovery on this import */
576 err = obd_set_info(obd->obd_self_export,
577 strlen("initial_recov"), "initial_recov",
578 sizeof(allow_recov), &allow_recov);
580 GOTO(out_cleanup, err);
582 err = obd_connect(&mdc_conn, obd, &mdc_uuid);
584 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
585 GOTO(out_cleanup, err);
588 exp = class_conn2export(&mdc_conn);
590 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
591 rc = class_config_process_llog(ctxt, profile, cfg);
593 CERROR("class_config_process_llog failed: rc = %d\n", rc);
595 err = obd_disconnect(exp, 0);
598 LCFG_INIT(lcfg, LCFG_CLEANUP, name);
599 err = class_process_config(&lcfg);
604 LCFG_INIT(lcfg, LCFG_DETACH, name);
605 err = class_process_config(&lcfg);
610 LCFG_INIT(lcfg, LCFG_DEL_UUID, name);
611 lcfg.lcfg_inllen1 = strlen(peer) + 1;
612 lcfg.lcfg_inlbuf1 = peer;
613 err = class_process_config(&lcfg);
616 if (lmd->lmd_nal == SOCKNAL) {
617 PCFG_INIT(pcfg, NAL_CMD_DEL_AUTOCONN);
618 pcfg.pcfg_nal = lmd->lmd_nal;
619 pcfg.pcfg_nid = lmd->lmd_server_nid;
620 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
621 pcfg.pcfg_flags = 1; /*share*/
622 err = libcfs_nal_cmd(&pcfg);
633 int lustre_fill_super(struct super_block *sb, void *data, int silent)
635 struct lustre_mount_data * lmd = data;
636 struct ll_sb_info *sbi;
642 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
643 if (lmd_bad_magic(lmd))
646 sbi = lustre_init_sbi(sb);
650 sbi->ll_flags |= LL_SBI_READAHEAD;
652 if (lmd->lmd_profile) {
653 struct lustre_profile *lprof;
654 struct config_llog_instance cfg;
657 if (lmd->lmd_mds[0] == '\0') {
658 CERROR("no mds name\n");
659 GOTO(out_free, err = -EINVAL);
662 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
663 if (sbi->ll_lmd == NULL)
664 GOTO(out_free, err = -ENOMEM);
665 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
667 /* generate a string unique to this super, let's try
668 the address of the super itself.*/
669 len = (sizeof(sb) * 2) + 1;
670 OBD_ALLOC(sbi->ll_instance, len);
671 if (sbi->ll_instance == NULL)
672 GOTO(out_free, err = -ENOMEM);
673 sprintf(sbi->ll_instance, "%p", sb);
675 cfg.cfg_instance = sbi->ll_instance;
676 cfg.cfg_uuid = sbi->ll_sb_uuid;
677 cfg.cfg_local_nid = lmd->lmd_local_nid;
678 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
680 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
684 lprof = class_get_profile(lmd->lmd_profile);
686 CERROR("No profile found: %s\n", lmd->lmd_profile);
687 GOTO(out_free, err = -EINVAL);
690 OBD_FREE(osc, strlen(osc) + 1);
691 OBD_ALLOC(osc, strlen(lprof->lp_osc) +
692 strlen(sbi->ll_instance) + 2);
693 sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance);
696 OBD_FREE(mdc, strlen(mdc) + 1);
697 OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
698 strlen(sbi->ll_instance) + 2);
699 sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance);
704 GOTO(out_free, err = -EINVAL);
709 GOTO(out_free, err = -EINVAL);
712 err = lustre_common_fill_super(sb, mdc, osc);
718 if (lmd->lmd_clone_index) {
719 err = lustre_set_clone_info(sb, lmd->lmd_clone_index);
728 OBD_FREE(mdc, strlen(mdc) + 1);
730 OBD_FREE(osc, strlen(osc) + 1);
736 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
739 if (sbi->ll_instance != NULL) {
740 struct lustre_mount_data *lmd = sbi->ll_lmd;
742 struct config_llog_instance cfg;
744 cfg.cfg_instance = sbi->ll_instance;
745 cfg.cfg_uuid = sbi->ll_sb_uuid;
747 OBD_ALLOC(cln_prof, len);
748 sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
750 err = lustre_process_log(lmd, cln_prof, &cfg, 0);
752 CERROR("Unable to process log: %s\n", cln_prof);
753 OBD_FREE(cln_prof, len);
754 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
756 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
759 lustre_cleanup_clone_info(sb);
764 } /* lustre_fill_super */
766 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
768 struct lustre_cfg lcfg;
769 struct obd_device *obd;
772 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
776 LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
777 err = class_process_config(&lcfg);
779 CERROR("cleanup failed: %s\n", obd->obd_name);
783 LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
784 err = class_process_config(&lcfg);
786 CERROR("detach failed: %s\n", obd->obd_name);
791 if (sbi->ll_lmd != NULL)
792 class_del_profile(sbi->ll_lmd->lmd_profile);
795 void lustre_put_super(struct super_block *sb)
797 struct obd_device *obd;
798 struct ll_sb_info *sbi = ll_s2sbi(sb);
799 int force_umount = 0;
802 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
803 obd = class_exp2obd(sbi->ll_mdc_exp);
805 force_umount = obd->obd_no_recov;
809 lustre_cleanup_clone_info(sb);
812 lustre_common_put_super(sb);
813 if (sbi->ll_lmd != NULL) {
815 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
817 struct config_llog_instance cfg;
820 CERROR("force umount, doing manual cleanup\n");
821 lustre_manual_cleanup(sbi);
825 cfg.cfg_instance = sbi->ll_instance;
826 cfg.cfg_uuid = sbi->ll_sb_uuid;
828 OBD_ALLOC(cln_prof, len);
829 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
831 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
833 CERROR("Unable to process log: %s, doing manual cleanup"
835 lustre_manual_cleanup(sbi);
838 OBD_FREE(cln_prof, len);
840 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
841 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
847 } /* lustre_put_super */
849 int ll_process_config_update(struct ll_sb_info *sbi, int clean)
851 struct obd_export *mdc_exp = sbi->ll_mdc_exp;
852 struct lustre_mount_data *lmd = sbi->ll_lmd;
853 struct llog_ctxt *ctxt;
854 struct config_llog_instance cfg;
855 char *profile = lmd->lmd_profile, *name = NULL;
856 int rc, namelen = 0, version;
862 CERROR("Client not mounted with zero-conf; cannot process "
867 rc = ldlm_cli_cancel_unused(mdc_exp->exp_obd->obd_namespace, NULL,
868 LDLM_FL_CONFIG_CHANGE, NULL);
870 CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
872 rc = obd_cancel_unused(sbi->ll_osc_exp, NULL, LDLM_FL_CONFIG_CHANGE,
875 CWARN("obd_cancel_unused(lov): %d\n", rc);
877 cfg.cfg_instance = sbi->ll_instance;
878 cfg.cfg_uuid = sbi->ll_sb_uuid;
879 cfg.cfg_local_nid = lmd->lmd_local_nid;
881 namelen = strlen(profile) + 20; /* -clean-######### */
882 OBD_ALLOC(name, namelen);
887 version = sbi->ll_config_version - 1;
888 sprintf(name, "%s-clean-%d", profile, version);
890 version = sbi->ll_config_version + 1;
891 sprintf(name, "%s-%d", profile, version);
894 CWARN("Applying configuration log %s\n", name);
896 ctxt = llog_get_context(&mdc_exp->exp_obd->obd_llogs,
897 LLOG_CONFIG_REPL_CTXT);
898 rc = class_config_process_llog(ctxt, name, &cfg);
900 sbi->ll_config_version = version;
901 CWARN("Finished applying configuration log %s: %d\n", name, rc);
903 if (rc == 0 && clean == 0) {
904 struct lov_desc desc;
906 valsize = sizeof(desc);
907 rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1,
908 "lovdesc", &valsize, &desc);
910 rc = obd_init_ea_size(mdc_exp,
911 obd_size_diskmd(sbi->ll_osc_exp, NULL),
913 sizeof(struct llog_cookie)));
915 OBD_FREE(name, namelen);
919 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
922 l_lock(&lock->l_resource->lr_namespace->ns_lock);
923 if (lock->l_ast_data)
924 inode = igrab(lock->l_ast_data);
927 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
931 int null_if_equal(struct ldlm_lock *lock, void *data)
933 if (data == lock->l_ast_data)
934 lock->l_ast_data = NULL;
936 if (lock->l_req_mode != lock->l_granted_mode)
937 return LDLM_ITER_STOP;
939 return LDLM_ITER_CONTINUE;
942 void ll_clear_inode(struct inode *inode)
945 struct ll_inode_info *lli = ll_i2info(inode);
946 struct ll_sb_info *sbi = ll_i2sbi(inode);
949 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
950 inode->i_generation, inode);
952 ll_inode2fid(&fid, inode);
953 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
954 md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
957 obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
958 null_if_equal, inode);
961 obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd);
966 /* FIXME: change cbdata for mea here */
967 obd_free_memmd(sbi->ll_mdc_exp,
968 (struct lov_stripe_md **) &lli->lli_mea);
972 if (lli->lli_symlink_name) {
973 OBD_FREE(lli->lli_symlink_name,
974 strlen(lli->lli_symlink_name) + 1);
975 lli->lli_symlink_name = NULL;
981 /* If this inode has objects allocated to it (lsm != NULL), then the OST
982 * object(s) determine the file size and mtime. Otherwise, the MDS will
983 * keep these values until such a time that objects are allocated for it.
984 * We do the MDS operations first, as it is checking permissions for us.
985 * We don't to the MDS RPC if there is nothing that we want to store there,
986 * otherwise there is no harm in updating mtime/atime on the MDS if we are
987 * going to do an RPC anyways.
989 * If we are doing a truncate, we will send the mtime and ctime updates
990 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
991 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
994 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
996 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
997 struct ll_sb_info *sbi = ll_i2sbi(inode);
998 struct ptlrpc_request *request = NULL;
999 struct mdc_op_data op_data;
1000 int ia_valid = attr->ia_valid;
1004 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
1005 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
1007 if (ia_valid & ATTR_SIZE) {
1008 if (attr->ia_size > ll_file_maxbytes(inode)) {
1009 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
1010 attr->ia_size, ll_file_maxbytes(inode));
1014 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
1017 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
1018 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
1019 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
1023 /* We mark all of the fields "set" so MDS/OST does not re-set them */
1024 if (attr->ia_valid & ATTR_CTIME) {
1025 attr->ia_ctime = CURRENT_TIME;
1026 attr->ia_valid |= ATTR_CTIME_SET;
1028 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
1029 attr->ia_atime = CURRENT_TIME;
1030 attr->ia_valid |= ATTR_ATIME_SET;
1032 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
1033 attr->ia_mtime = CURRENT_TIME;
1034 attr->ia_valid |= ATTR_MTIME_SET;
1037 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
1038 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
1039 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
1040 LTIME_S(CURRENT_TIME));
1042 attr->ia_valid &= ~ATTR_SIZE;
1044 /* If only OST attributes being set on objects, don't do MDS RPC.
1045 * In that case, we need to check permissions and update the local
1046 * inode ourselves so we can call obdo_from_inode() always. */
1047 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
1048 struct lustre_md md;
1049 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1051 rc = md_setattr(sbi->ll_mdc_exp, &op_data,
1052 attr, NULL, 0, NULL, 0, &request);
1054 ptlrpc_req_finished(request);
1055 if (rc != -EPERM && rc != -EACCES)
1056 CERROR("md_setattr fails: rc = %d\n", rc);
1060 rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0,
1061 sbi->ll_osc_exp, &md);
1063 ptlrpc_req_finished(request);
1067 /* Won't invoke vmtruncate as we already cleared ATTR_SIZE,
1068 * but needed to set timestamps backwards on utime. */
1069 inode_setattr(inode, attr);
1070 ll_update_inode(inode, &md);
1071 ptlrpc_req_finished(request);
1073 if (!lsm || !S_ISREG(inode->i_mode)) {
1074 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
1078 /* The OST doesn't check permissions, but the alternative is
1079 * a gratuitous RPC to the MDS. We already rely on the client
1080 * to do read/write/truncate permission checks, so is mtime OK?
1082 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
1083 /* from sys_utime() */
1084 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
1085 if (current->fsuid != inode->i_uid &&
1086 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1089 /* from inode_change_ok() */
1090 if (current->fsuid != inode->i_uid &&
1091 !capable(CAP_FOWNER))
1096 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1097 inode_setattr(inode, attr);
1100 /* We really need to get our PW lock before we change inode->i_size.
1101 * If we don't we can race with other i_size updaters on our node, like
1102 * ll_file_read. We can also race with i_size propogation to other
1103 * nodes through dirtying and writeback of final cached pages. This
1104 * last one is especially bad for racing o_append users on other
1106 if (ia_valid & ATTR_SIZE) {
1107 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1109 struct lustre_handle lockh = { 0 };
1110 int err, ast_flags = 0;
1111 /* XXX when we fix the AST intents to pass the discard-range
1112 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1114 if (attr->ia_size == 0)
1115 ast_flags = LDLM_AST_DISCARD_DATA;
1117 /* bug 1639: avoid write/truncate i_sem/DLM deadlock */
1118 LASSERT(atomic_read(&inode->i_sem.count) <= 0);
1120 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1122 down(&inode->i_sem);
1126 rc = vmtruncate(inode, attr->ia_size);
1128 /* We need to drop the semaphore here, because this unlock may
1129 * result in a cancellation, which will need the i_sem */
1131 /* unlock now as we don't mind others file lockers racing with
1132 * the mds updates below? */
1133 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1134 down(&inode->i_sem);
1136 CERROR("ll_extent_unlock failed: %d\n", err);
1140 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1143 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1144 inode->i_ino, LTIME_S(attr->ia_mtime));
1145 oa.o_id = lsm->lsm_object_id;
1146 oa.o_gr = lsm->lsm_object_gr;
1147 oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1148 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1149 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1150 rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL);
1152 CERROR("obd_setattr fails: rc=%d\n", rc);
1157 int ll_setattr(struct dentry *de, struct iattr *attr)
1159 LBUG(); /* code is unused, but leave this in case of VFS changes */
1163 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1164 unsigned long max_age)
1166 struct ll_sb_info *sbi = ll_s2sbi(sb);
1167 struct obd_statfs obd_osfs;
1171 rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age);
1173 CERROR("mdc_statfs fails: rc = %d\n", rc);
1177 osfs->os_type = sb->s_magic;
1179 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1180 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1182 rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age);
1184 CERROR("obd_statfs fails: rc = %d\n", rc);
1188 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1189 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1192 osfs->os_blocks = obd_osfs.os_blocks;
1193 osfs->os_bfree = obd_osfs.os_bfree;
1194 osfs->os_bavail = obd_osfs.os_bavail;
1196 /* If we don't have as many objects free on the OST as inodes
1197 * on the MDS, we reduce the total number of inodes to
1198 * compensate, so that the "inodes in use" number is correct.
1200 if (obd_osfs.os_ffree < osfs->os_ffree) {
1201 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1203 osfs->os_ffree = obd_osfs.os_ffree;
1209 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1211 struct obd_statfs osfs;
1214 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1215 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1217 /* For now we will always get up-to-date statfs values, but in the
1218 * future we may allow some amount of caching on the client (e.g.
1219 * from QOS or lprocfs updates). */
1220 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1224 statfs_unpack(sfs, &osfs);
1226 if (sizeof(sfs->f_blocks) == 4) {
1227 while (osfs.os_blocks > ~0UL) {
1230 osfs.os_blocks >>= 1;
1231 osfs.os_bfree >>= 1;
1232 osfs.os_bavail >>= 1;
1236 sfs->f_blocks = osfs.os_blocks;
1237 sfs->f_bfree = osfs.os_bfree;
1238 sfs->f_bavail = osfs.os_bavail;
1243 void dump_lsm(int level, struct lov_stripe_md *lsm)
1245 CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
1246 "stripe_size %u, stripe_count %u\n",
1247 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
1248 lsm->lsm_stripe_size, lsm->lsm_stripe_count);
1251 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1253 struct ll_inode_info *lli = ll_i2info(inode);
1254 struct mds_body *body = md->body;
1255 struct lov_stripe_md *lsm = md->lsm;
1256 struct mea *mea = md->mea;
1259 LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1260 LASSERT((mea != NULL) == ((body->valid & OBD_MD_FLDIREA) != 0));
1262 LASSERT(lsm->lsm_object_gr > 0);
1263 if (lli->lli_smd == NULL) {
1265 lli->lli_maxbytes = lsm->lsm_maxbytes;
1266 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1267 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1270 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1271 CERROR("lsm mismatch for inode %ld\n",
1273 CERROR("lli_smd:\n");
1274 dump_lsm(D_ERROR, lli->lli_smd);
1276 dump_lsm(D_ERROR, lsm);
1279 /* XXX FIXME -- We should decide on a safer (atomic) and
1280 * more elegant way to update the lsm */
1281 for (i = 0; i < lsm->lsm_stripe_count; i++) {
1282 lli->lli_smd->lsm_oinfo[i].loi_id =
1283 lsm->lsm_oinfo[i].loi_id;
1284 lli->lli_smd->lsm_oinfo[i].loi_gr =
1285 lsm->lsm_oinfo[i].loi_gr;
1286 lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
1287 lsm->lsm_oinfo[i].loi_ost_idx;
1288 lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
1289 lsm->lsm_oinfo[i].loi_ost_gen;
1292 /* bug 2844 - limit i_blksize for broken user-space apps */
1293 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1294 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1295 if (lli->lli_smd != lsm)
1296 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1300 if (lli->lli_mea == NULL) {
1303 if (memcmp(lli->lli_mea, mea, body->eadatasize)) {
1304 CERROR("mea mismatch for inode %lu\n",
1309 if (lli->lli_mea != mea)
1310 obd_free_memmd(ll_i2mdcexp(inode),
1311 (struct lov_stripe_md **) &mea);
1315 if (body->valid & OBD_MD_FLID)
1316 inode->i_ino = body->ino;
1317 if (body->valid & OBD_MD_FLATIME)
1318 LTIME_S(inode->i_atime) = body->atime;
1319 if (body->valid & OBD_MD_FLMTIME &&
1320 body->mtime > LTIME_S(inode->i_mtime)) {
1321 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1322 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1323 LTIME_S(inode->i_mtime) = body->mtime;
1325 if (body->valid & OBD_MD_FLCTIME &&
1326 body->ctime > LTIME_S(inode->i_ctime))
1327 LTIME_S(inode->i_ctime) = body->ctime;
1328 if (body->valid & OBD_MD_FLMODE)
1329 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
1330 if (body->valid & OBD_MD_FLTYPE)
1331 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
1332 if (body->valid & OBD_MD_FLUID)
1333 inode->i_uid = body->uid;
1334 if (body->valid & OBD_MD_FLGID)
1335 inode->i_gid = body->gid;
1336 if (body->valid & OBD_MD_FLFLAGS)
1337 inode->i_flags = body->flags;
1338 if (body->valid & OBD_MD_FLNLINK)
1339 inode->i_nlink = body->nlink;
1340 if (body->valid & OBD_MD_FLGENER)
1341 inode->i_generation = body->generation;
1342 if (body->valid & OBD_MD_FLRDEV)
1343 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1344 inode->i_rdev = body->rdev;
1346 inode->i_rdev = old_decode_dev(body->rdev);
1348 if (body->valid & OBD_MD_FLSIZE)
1349 inode->i_size = body->size;
1350 if (body->valid & OBD_MD_FLBLOCKS)
1351 inode->i_blocks = body->blocks;
1353 if (body->valid & OBD_MD_FLSIZE)
1354 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1356 lli->lli_mds = body->mds;
1357 inode->i_dev = (kdev_t) body->mds;
1358 LASSERT(body->mds < 1000);
1361 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1362 static struct backing_dev_info ll_backing_dev_info = {
1363 .ra_pages = 0, /* No readahead */
1364 .memory_backed = 0, /* Does contribute to dirty memory */
1368 void ll_read_inode2(struct inode *inode, void *opaque)
1370 struct lustre_md *md = opaque;
1371 struct ll_inode_info *lli = ll_i2info(inode);
1374 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1375 inode->i_generation, inode);
1379 LASSERT(!lli->lli_smd);
1381 /* Core attributes from the MDS first. This is a new inode, and
1382 * the VFS doesn't zero times in the core inode so we have to do
1383 * it ourselves. They will be overwritten by either MDS or OST
1384 * attributes - we just need to make sure they aren't newer. */
1385 LTIME_S(inode->i_mtime) = 0;
1386 LTIME_S(inode->i_atime) = 0;
1387 LTIME_S(inode->i_ctime) = 0;
1390 ll_update_inode(inode, md);
1392 /* OIDEBUG(inode); */
1394 if (S_ISREG(inode->i_mode)) {
1395 inode->i_op = &ll_file_inode_operations;
1396 inode->i_fop = &ll_file_operations;
1397 inode->i_mapping->a_ops = &ll_aops;
1399 } else if (S_ISDIR(inode->i_mode)) {
1400 inode->i_op = &ll_dir_inode_operations;
1401 inode->i_fop = &ll_dir_operations;
1402 inode->i_mapping->a_ops = &ll_dir_aops;
1404 } else if (S_ISLNK(inode->i_mode)) {
1405 inode->i_op = &ll_fast_symlink_inode_operations;
1408 inode->i_op = &ll_special_inode_operations;
1410 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1411 init_special_inode(inode, inode->i_mode,
1412 kdev_t_to_nr(inode->i_rdev));
1414 /* initializing backing dev info. */
1415 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1417 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1419 lli->ll_save_ifop = inode->i_fop;
1421 if (S_ISCHR(inode->i_mode))
1422 inode->i_fop = &ll_special_chr_inode_fops;
1423 else if (S_ISBLK(inode->i_mode))
1424 inode->i_fop = &ll_special_blk_inode_fops;
1425 else if (S_ISFIFO(inode->i_mode))
1426 inode->i_fop = &ll_special_fifo_inode_fops;
1427 else if (S_ISSOCK(inode->i_mode))
1428 inode->i_fop = &ll_special_sock_inode_fops;
1430 CWARN("saved %p, replaced with %p\n", lli->ll_save_ifop,
1433 if (lli->ll_save_ifop->owner) {
1434 CWARN("%p has owner %p\n", lli->ll_save_ifop,
1435 lli->ll_save_ifop->owner);
1441 void ll_delete_inode(struct inode *inode)
1445 struct ll_sb_info *sbi = ll_i2sbi(inode);
1448 ll_inode2fid(&fid, inode);
1450 rc = md_delete_object(sbi->ll_mdc_exp, &fid);
1452 CERROR("md_delete_object() failed, error %d.\n",
1460 int ll_iocontrol(struct inode *inode, struct file *file,
1461 unsigned int cmd, unsigned long arg)
1463 struct ll_sb_info *sbi = ll_i2sbi(inode);
1464 struct ptlrpc_request *req = NULL;
1469 case EXT3_IOC_GETFLAGS: {
1471 unsigned long valid = OBD_MD_FLFLAGS;
1472 struct mds_body *body;
1474 ll_inode2fid(&fid, inode);
1475 rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, 0, &req);
1477 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1481 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1483 if (body->flags & S_APPEND)
1484 flags |= EXT3_APPEND_FL;
1485 if (body->flags & S_IMMUTABLE)
1486 flags |= EXT3_IMMUTABLE_FL;
1487 if (body->flags & S_NOATIME)
1488 flags |= EXT3_NOATIME_FL;
1490 ptlrpc_req_finished (req);
1492 RETURN(put_user(flags, (int *)arg));
1494 case EXT3_IOC_SETFLAGS: {
1495 struct mdc_op_data op_data;
1498 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1500 if (get_user(flags, (int *)arg))
1507 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1509 memset(&attr, 0x0, sizeof(attr));
1510 attr.ia_attr_flags = flags;
1511 attr.ia_valid |= ATTR_ATTR_FLAG;
1513 rc = md_setattr(sbi->ll_mdc_exp, &op_data,
1514 &attr, NULL, 0, NULL, 0, &req);
1516 ptlrpc_req_finished(req);
1517 if (rc != -EPERM && rc != -EACCES)
1518 CERROR("md_setattr fails: rc = %d\n", rc);
1522 ptlrpc_req_finished(req);
1524 oa->o_id = lsm->lsm_object_id;
1525 oa->o_gr = lsm->lsm_object_gr;
1526 oa->o_flags = flags;
1527 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
1529 rc = obd_setattr(sbi->ll_osc_exp, oa, lsm, NULL);
1532 if (rc != -EPERM && rc != -EACCES)
1533 CERROR("md_setattr fails: rc = %d\n", rc);
1537 if (flags & EXT3_APPEND_FL)
1538 inode->i_flags |= S_APPEND;
1540 inode->i_flags &= ~S_APPEND;
1541 if (flags & EXT3_IMMUTABLE_FL)
1542 inode->i_flags |= S_IMMUTABLE;
1544 inode->i_flags &= ~S_IMMUTABLE;
1545 if (flags & EXT3_NOATIME_FL)
1546 inode->i_flags |= S_NOATIME;
1548 inode->i_flags &= ~S_NOATIME;
1559 void ll_umount_begin(struct super_block *sb)
1561 struct ll_sb_info *sbi = ll_s2sbi(sb);
1562 struct obd_device *obd;
1563 struct obd_ioctl_data ioc_data = { 0 };
1565 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1567 obd = class_exp2obd(sbi->ll_mdc_exp);
1569 CERROR("Invalid MDC connection handle "LPX64"\n",
1570 sbi->ll_mdc_exp->exp_handle.h_cookie);
1574 obd->obd_no_recov = 1;
1575 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data,
1578 obd = class_exp2obd(sbi->ll_osc_exp);
1580 CERROR("Invalid LOV connection handle "LPX64"\n",
1581 sbi->ll_osc_exp->exp_handle.h_cookie);
1586 obd->obd_no_recov = 1;
1587 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data,
1590 /* Really, we'd like to wait until there are no requests outstanding,
1591 * and then continue. For now, we just invalidate the requests,
1592 * schedule, and hope.
1599 int ll_prep_inode(struct obd_export *osc_exp, struct obd_export *mdc_exp,
1600 struct inode **inode, struct ptlrpc_request *req,
1601 int offset, struct super_block *sb)
1603 struct lustre_md md;
1606 rc = mdc_req2lustre_md(mdc_exp, req, offset, osc_exp, &md);
1611 ll_update_inode(*inode, &md);
1614 *inode = ll_iget(sb, md.body->ino, &md);
1615 if (*inode == NULL || is_bad_inode(*inode)) {
1616 /* free the lsm if we allocated one above */
1618 obd_free_memmd(osc_exp, &md.lsm);
1620 obd_free_memmd(mdc_exp,
1621 (struct lov_stripe_md**)&md.mea);
1623 CERROR("new_inode -fatal: rc %d\n", rc);