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-2005 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 LIST_HEAD(ll_super_blocks);
40 spinlock_t ll_sb_lock = SPIN_LOCK_UNLOCKED;
42 extern struct address_space_operations ll_aops;
43 extern struct address_space_operations ll_dir_aops;
46 #define log2(n) ffz(~(n))
49 /* We need to have some extra twiddling here because some systems have
50 * no random state when they start up. */
52 lustre_generate_random_uuid(class_uuid_t uuid)
58 LASSERT(sizeof(class_uuid_t) % sizeof(*i) == 0);
64 generate_random_uuid(uuid);
66 for (i = (int *)uuid; (char *)i < (char *)uuid + sizeof(class_uuid_t); i++) {
68 j = ((j << 8) & 0xffffff00) | ((j >> 24) & 0x000000ff);
69 k = ((k >> 8) & 0x00ffffff) | ((k << 24) & 0xff000000);
75 struct ll_sb_info *lustre_init_sbi(struct super_block *sb)
77 struct ll_sb_info *sbi = NULL;
81 OBD_ALLOC(sbi, sizeof(*sbi));
85 spin_lock_init(&sbi->ll_lock);
86 INIT_LIST_HEAD(&sbi->ll_pglist);
87 sbi->ll_pglist_gen = 0;
88 if (num_physpages >> (20 - PAGE_SHIFT) < 512)
89 sbi->ll_async_page_max = num_physpages / 2;
91 sbi->ll_async_page_max = (num_physpages / 4) * 3;
92 sbi->ll_ra_info.ra_max_pages = min(num_physpages / 8,
93 SBI_DEFAULT_READAHEAD_MAX);
95 INIT_LIST_HEAD(&sbi->ll_conn_chain);
96 INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
97 ll_s2sbi_nocast(sb) = sbi;
99 lustre_generate_random_uuid(uuid);
100 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
101 CDEBUG(D_HA, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
103 spin_lock(&ll_sb_lock);
104 list_add_tail(&sbi->ll_list, &ll_super_blocks);
105 spin_unlock(&ll_sb_lock);
109 void lustre_free_sbi(struct super_block *sb)
111 struct ll_sb_info *sbi = ll_s2sbi(sb);
115 spin_lock(&ll_sb_lock);
116 list_del(&sbi->ll_list);
117 spin_unlock(&ll_sb_lock);
118 OBD_FREE(sbi, sizeof(*sbi));
120 ll_s2sbi_nocast(sb) = NULL;
124 int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc)
126 struct inode *root = 0;
127 struct ll_sb_info *sbi = ll_s2sbi(sb);
128 struct obd_device *obd;
129 struct ll_fid rootfid;
130 struct obd_statfs osfs;
131 struct ptlrpc_request *request = NULL;
132 struct lustre_handle osc_conn = {0, };
133 struct lustre_handle mdc_conn = {0, };
135 struct obd_connect_data *data = NULL;
140 obd = class_name2obd(mdc);
142 CERROR("MDC %s: not setup or attached\n", mdc);
146 OBD_ALLOC(data, sizeof(*data));
150 if (proc_lustre_fs_root) {
151 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
154 CERROR("could not register mount in /proc/lustre");
157 if (sb->s_flags & MS_RDONLY)
158 data->ocd_connect_flags |= OBD_CONNECT_RDONLY;
160 err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, data);
162 CERROR("An MDS (mdc %s) is performing recovery, of which this"
163 " client is not a part. Please wait for recovery to "
164 "complete, abort, or time out.\n", mdc);
167 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
170 sbi->ll_mdc_exp = class_conn2export(&mdc_conn);
172 err = obd_statfs(obd, &osfs, jiffies - HZ);
176 LASSERT(osfs.os_bsize);
177 sb->s_blocksize = osfs.os_bsize;
178 sb->s_blocksize_bits = log2(osfs.os_bsize);
179 sb->s_magic = LL_SUPER_MAGIC;
180 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
181 sbi->ll_namelen = osfs.os_namelen;
183 devno = get_uuid2int(sbi2mdc(sbi)->cl_import->imp_target_uuid.uuid,
184 strlen(sbi2mdc(sbi)->cl_import->imp_target_uuid.uuid));
185 /* s_dev is also used in lt_compare() to compare two fs */
188 obd = class_name2obd(osc);
190 CERROR("OSC %s: not setup or attached\n", osc);
194 err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, data);
196 CERROR("An OST (osc %s) is performing recovery, of which this"
197 " client is not a part. Please wait for recovery to "
198 "complete, abort, or time out.\n", osc);
201 CERROR("cannot connect to %s: rc = %d\n", osc, err);
204 sbi->ll_osc_exp = class_conn2export(&osc_conn);
206 mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
208 if (!ll_async_page_slab) {
209 ll_async_page_slab_size =
210 size_round(sizeof(struct ll_async_page)) +
211 obd_prep_async_page(sbi->ll_osc_exp, NULL, NULL, NULL,
212 0, NULL, NULL, NULL);
213 ll_async_page_slab = kmem_cache_create("ll_async_page",
214 ll_async_page_slab_size,
216 if (!ll_async_page_slab)
217 GOTO(out_osc, -ENOMEM);
220 err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid);
222 CERROR("cannot mds_connect: rc = %d\n", err);
225 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
226 sbi->ll_rootino = rootfid.id;
228 sb->s_op = &lustre_super_operations;
231 * XXX: move this to after cbd setup? */
232 err = mdc_getattr(sbi->ll_mdc_exp, &rootfid,
233 OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
235 CERROR("mdc_getattr failed for root: rc = %d\n", err);
239 err = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
241 CERROR("failed to understand root inode md: rc = %d\n",err);
242 ptlrpc_req_finished (request);
246 LASSERT(sbi->ll_rootino != 0);
247 root = ll_iget(sb, sbi->ll_rootino, &md);
249 ptlrpc_req_finished(request);
251 if (root == NULL || is_bad_inode(root)) {
252 /* XXX might need iput() for bad inode */
253 CERROR("lustre_lite: bad iget4 for root\n");
254 GOTO(out_root, err = -EBADF);
257 err = ll_close_thread_start(&sbi->ll_lcq);
259 CERROR("cannot start close thread: rc %d\n", err);
263 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x,
264 backing dev info assigned to inode mapping is used for
265 determining maximal readahead. */
266 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
267 !defined(KERNEL_HAS_AS_MAX_READAHEAD)
268 /* bug 2805 - set VM readahead to zero */
269 vm_max_readahead = vm_min_readahead = 0;
272 sb->s_root = d_alloc_root(root);
274 OBD_FREE(data, sizeof(*data));
281 obd_disconnect(sbi->ll_osc_exp);
283 obd_disconnect(sbi->ll_mdc_exp);
286 OBD_FREE(data, sizeof(*data));
287 lprocfs_unregister_mountpoint(sbi);
291 void lustre_dump_inode(struct inode *inode)
293 struct list_head *tmp;
294 int dentry_count = 0;
295 BDEVNAME_DECLARE_STORAGE(buf);
297 LASSERT(inode != NULL);
299 list_for_each(tmp, &inode->i_dentry)
302 CERROR("inode %p dump: dev=%s:%lu, mode=%o, count=%u, %d dentries\n",
303 inode, ll_bdevname(inode->i_sb, buf), inode->i_ino,
304 inode->i_mode, atomic_read(&inode->i_count), dentry_count);
307 void lustre_dump_dentry(struct dentry *dentry, int recur)
309 struct list_head *tmp;
312 LASSERT(dentry != NULL);
314 list_for_each(tmp, &dentry->d_subdirs)
317 CERROR("dentry %p dump: name=%.*s parent=%.*s (%p), inode=%p, count=%u,"
318 " flags=0x%x, vfs_flags=0x%x, fsdata=%p, %d subdirs\n", dentry,
319 dentry->d_name.len, dentry->d_name.name,
320 dentry->d_parent->d_name.len, dentry->d_parent->d_name.name,
321 dentry->d_parent, dentry->d_inode, atomic_read(&dentry->d_count),
322 dentry->d_flags, dentry->d_flags, dentry->d_fsdata, subdirs);
323 if (dentry->d_inode != NULL)
324 lustre_dump_inode(dentry->d_inode);
329 list_for_each(tmp, &dentry->d_subdirs) {
330 struct dentry *d = list_entry(tmp, struct dentry, d_child);
331 lustre_dump_dentry(d, recur - 1);
335 void lustre_common_put_super(struct super_block *sb)
337 struct ll_sb_info *sbi = ll_s2sbi(sb);
338 struct hlist_node *tmp, *next;
341 ll_close_thread_shutdown(sbi->ll_lcq);
343 list_del(&sbi->ll_conn_chain);
344 obd_disconnect(sbi->ll_osc_exp);
346 lprocfs_unregister_mountpoint(sbi);
347 if (sbi->ll_proc_root) {
348 lprocfs_remove(sbi->ll_proc_root);
349 sbi->ll_proc_root = NULL;
352 obd_disconnect(sbi->ll_mdc_exp);
354 // We do this to get rid of orphaned dentries. That is not really trw.
355 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
356 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
357 CWARN("found orphan dentry %.*s (%p->%p) at unmount, dumping "
358 "before and after shrink_dcache_parent\n",
359 dentry->d_name.len, dentry->d_name.name, dentry, next);
360 lustre_dump_dentry(dentry, 1);
361 shrink_dcache_parent(dentry);
362 lustre_dump_dentry(dentry, 1);
367 char *ll_read_opt(const char *opt, char *data)
373 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
374 if (strncmp(opt, data, strlen(opt)))
376 if ((value = strchr(data, '=')) == NULL)
380 OBD_ALLOC(retval, strlen(value) + 1);
382 CERROR("out of memory!\n");
386 memcpy(retval, value, strlen(value)+1);
387 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
391 int ll_set_opt(const char *opt, char *data, int fl)
395 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
396 if (strncmp(opt, data, strlen(opt)))
402 void ll_options(char *options, char **ost, char **mdc, int *flags)
405 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
406 char *opt_ptr = options;
415 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
416 for (this_char = strtok (options, ",");
418 this_char = strtok (NULL, ","))
420 while ((this_char = strsep (&opt_ptr, ",")) != NULL)
423 CDEBUG(D_SUPER, "this_char %s\n", this_char);
424 if (!*ost && (*ost = ll_read_opt("osc", this_char)))
426 if (!*mdc && (*mdc = ll_read_opt("mdc", this_char)))
428 if (!(*flags & LL_SBI_NOLCK) &&
429 ((*flags) = (*flags) |
430 ll_set_opt("nolock", this_char,
437 void ll_lli_init(struct ll_inode_info *lli)
439 sema_init(&lli->lli_open_sem, 1);
440 sema_init(&lli->lli_size_sem, 1);
441 lli->lli_size_pid = 0;
443 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
444 spin_lock_init(&lli->lli_lock);
445 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
446 lli->lli_inode_magic = LLI_INODE_MAGIC;
449 int ll_fill_super(struct super_block *sb, void *data, int silent)
451 struct ll_sb_info *sbi;
457 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
459 sbi = lustre_init_sbi(sb);
463 ll_options(data, &osc, &mdc, &sbi->ll_flags);
467 GOTO(out, err = -EINVAL);
472 GOTO(out, err = -EINVAL);
475 err = lustre_common_fill_super(sb, mdc, osc);
481 OBD_FREE(mdc, strlen(mdc) + 1);
483 OBD_FREE(osc, strlen(osc) + 1);
486 } /* ll_read_super */
488 int lustre_process_log(struct lustre_mount_data *lmd, char * profile,
489 struct config_llog_instance *cfg, int allow_recov)
491 struct lustre_cfg *lcfg = NULL;
492 struct lustre_cfg_bufs bufs;
493 struct portals_cfg pcfg;
494 char * peer = "MDS_PEER_UUID";
495 struct obd_device *obd;
496 struct lustre_handle mdc_conn = {0, };
497 struct obd_export *exp;
498 char * name = "mdc_dev";
500 struct obd_uuid mdc_uuid;
501 struct llog_ctxt *ctxt;
506 if (lmd_bad_magic(lmd))
509 lustre_generate_random_uuid(uuid);
510 class_uuid_unparse(uuid, &mdc_uuid);
511 CDEBUG(D_HA, "generated uuid: %s\n", mdc_uuid.uuid);
513 if (lmd->lmd_local_nid) {
514 PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID);
515 pcfg.pcfg_nal = lmd->lmd_nal;
516 pcfg.pcfg_nid = lmd->lmd_local_nid;
517 err = libcfs_nal_cmd(&pcfg);
522 if (lmd->lmd_nal == SOCKNAL ||
523 lmd->lmd_nal == OPENIBNAL ||
524 lmd->lmd_nal == IIBNAL ||
525 lmd->lmd_nal == VIBNAL ||
526 lmd->lmd_nal == RANAL) {
527 PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);
528 pcfg.pcfg_nal = lmd->lmd_nal;
529 pcfg.pcfg_nid = lmd->lmd_server_nid;
530 pcfg.pcfg_id = lmd->lmd_server_ipaddr;
531 pcfg.pcfg_misc = lmd->lmd_port;
532 err = libcfs_nal_cmd(&pcfg);
537 lustre_cfg_bufs_reset(&bufs, name);
538 lustre_cfg_bufs_set_string(&bufs, 1, peer);
540 lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs);
541 lcfg->lcfg_nal = lmd->lmd_nal;
542 lcfg->lcfg_nid = lmd->lmd_server_nid;
543 LASSERT(lcfg->lcfg_nal);
544 LASSERT(lcfg->lcfg_nid);
545 err = class_process_config(lcfg);
546 lustre_cfg_free(lcfg);
548 GOTO(out_del_conn, err);
550 lustre_cfg_bufs_reset(&bufs, name);
551 lustre_cfg_bufs_set_string(&bufs, 1, LUSTRE_MDC_NAME);
552 lustre_cfg_bufs_set_string(&bufs, 2, mdc_uuid.uuid);
554 lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
555 err = class_process_config(lcfg);
556 lustre_cfg_free(lcfg);
558 GOTO(out_del_uuid, err);
560 lustre_cfg_bufs_reset(&bufs, name);
561 lustre_cfg_bufs_set_string(&bufs, 1, lmd->lmd_mds);
562 lustre_cfg_bufs_set_string(&bufs, 2, peer);
564 lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
565 err = class_process_config(lcfg);
566 lustre_cfg_free(lcfg);
568 GOTO(out_detach, err);
570 obd = class_name2obd(name);
572 GOTO(out_cleanup, err = -EINVAL);
574 /* Disable initial recovery on this import */
575 err = obd_set_info(obd->obd_self_export,
576 strlen("initial_recov"), "initial_recov",
577 sizeof(allow_recov), &allow_recov);
579 GOTO(out_cleanup, err);
581 err = obd_connect(&mdc_conn, obd, &mdc_uuid, NULL /* ocd */);
583 CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
584 GOTO(out_cleanup, err);
587 exp = class_conn2export(&mdc_conn);
589 ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
591 rc = class_config_parse_llog(ctxt, profile, cfg);
594 * For debugging, it's useful to just dump the log
596 rc = class_config_dump_llog(ctxt, profile, cfg);
602 LCONSOLE_ERROR("%s: The configuration '%s' could not be read "
603 "from the MDS. Make sure this client and the "
604 "MDS are running compatible versions of "
606 obd->obd_name, profile);
609 CERROR("class_config_parse_llog failed: rc = %d\n", rc);
613 err = obd_disconnect(exp);
616 lustre_cfg_bufs_reset(&bufs, name);
617 lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs);
618 err = class_process_config(lcfg);
619 lustre_cfg_free(lcfg);
624 lustre_cfg_bufs_reset(&bufs, name);
625 lcfg = lustre_cfg_new(LCFG_DETACH, &bufs);
626 err = class_process_config(lcfg);
627 lustre_cfg_free(lcfg);
632 lustre_cfg_bufs_reset(&bufs, name);
633 lustre_cfg_bufs_set_string(&bufs, 1, peer);
634 lcfg = lustre_cfg_new(LCFG_DEL_UUID, &bufs);
635 err = class_process_config(lcfg);
636 lustre_cfg_free(lcfg);
639 if (lmd->lmd_nal == SOCKNAL ||
640 lmd->lmd_nal == OPENIBNAL ||
641 lmd->lmd_nal == IIBNAL ||
642 lmd->lmd_nal == VIBNAL ||
643 lmd->lmd_nal == RANAL) {
644 PCFG_INIT(pcfg, NAL_CMD_DEL_PEER);
645 pcfg.pcfg_nal = lmd->lmd_nal;
646 pcfg.pcfg_nid = lmd->lmd_server_nid;
647 pcfg.pcfg_flags = 1; /* single_share */
648 err = libcfs_nal_cmd(&pcfg);
659 static void lustre_manual_cleanup(struct ll_sb_info *sbi)
661 struct lustre_cfg *lcfg;
662 struct lustre_cfg_bufs bufs;
663 struct obd_device *obd;
666 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL){
669 /* the lcfg is almost the same for both ops */
670 lustre_cfg_bufs_reset(&bufs, obd->obd_name);
671 lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs);
673 err = class_process_config(lcfg);
675 CERROR("cleanup failed: %s\n", obd->obd_name);
679 lcfg->lcfg_command = LCFG_DETACH;
680 err = class_process_config(lcfg);
681 lustre_cfg_free(lcfg);
683 CERROR("detach failed: %s\n", obd->obd_name);
688 if (sbi->ll_lmd != NULL)
689 class_del_profile(sbi->ll_lmd->lmd_profile);
692 int lustre_fill_super(struct super_block *sb, void *data, int silent)
694 struct lustre_mount_data * lmd = data;
695 struct ll_sb_info *sbi;
701 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
702 if (lmd_bad_magic(lmd))
705 sbi = lustre_init_sbi(sb);
709 if (lmd->lmd_profile) {
710 struct lustre_profile *lprof;
711 struct config_llog_instance cfg;
714 if (lmd->lmd_mds[0] == '\0') {
715 CERROR("no mds name\n");
716 GOTO(out_free, err = -EINVAL);
719 OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
720 if (sbi->ll_lmd == NULL)
721 GOTO(out_free, err = -ENOMEM);
722 memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
724 /* generate a string unique to this super, let's try
725 the address of the super itself.*/
726 len = (sizeof(sb) * 2) + 1;
727 OBD_ALLOC(sbi->ll_instance, len);
728 if (sbi->ll_instance == NULL)
729 GOTO(out_free, err = -ENOMEM);
730 sprintf(sbi->ll_instance, "%p", sb);
732 cfg.cfg_instance = sbi->ll_instance;
733 cfg.cfg_uuid = sbi->ll_sb_uuid;
734 cfg.cfg_local_nid = lmd->lmd_local_nid;
735 err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
737 CERROR("Unable to process log: %s\n", lmd->lmd_profile);
742 lprof = class_get_profile(lmd->lmd_profile);
744 CERROR("No profile found: %s\n", lmd->lmd_profile);
745 GOTO(out_free, err = -EINVAL);
748 OBD_FREE(osc, strlen(osc) + 1);
749 OBD_ALLOC(osc, strlen(lprof->lp_osc) +
750 strlen(sbi->ll_instance) + 2);
751 sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance);
754 OBD_FREE(mdc, strlen(mdc) + 1);
755 OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
756 strlen(sbi->ll_instance) + 2);
757 sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance);
762 GOTO(out_free, err = -EINVAL);
767 GOTO(out_free, err = -EINVAL);
770 err = lustre_common_fill_super(sb, mdc, osc);
777 OBD_FREE(mdc, strlen(mdc) + 1);
779 OBD_FREE(osc, strlen(osc) + 1);
785 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
788 if (sbi->ll_instance != NULL) {
790 struct config_llog_instance cfg;
792 cfg.cfg_instance = sbi->ll_instance;
793 cfg.cfg_uuid = sbi->ll_sb_uuid;
795 OBD_ALLOC(cln_prof, len);
796 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
798 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg,0);
800 CERROR("Unable to process log: %s\n", cln_prof);
801 lustre_manual_cleanup(sbi);
803 OBD_FREE(cln_prof, len);
804 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance)+ 1);
806 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
811 } /* lustre_fill_super */
813 void lustre_put_super(struct super_block *sb)
815 struct obd_device *obd;
816 struct ll_sb_info *sbi = ll_s2sbi(sb);
817 int force_umount = 0;
820 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
821 obd = class_exp2obd(sbi->ll_mdc_exp);
823 force_umount = obd->obd_no_recov;
826 lustre_common_put_super(sb);
828 if (sbi->ll_lmd != NULL) {
831 int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
833 struct config_llog_instance cfg;
836 CERROR("force umount, doing manual cleanup\n");
837 lustre_manual_cleanup(sbi);
841 cfg.cfg_instance = sbi->ll_instance;
842 cfg.cfg_uuid = sbi->ll_sb_uuid;
844 OBD_ALLOC(cln_prof, len);
845 sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
847 err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg, 0);
849 CERROR("Unable to process log: %s, doing manual cleanup"
851 lustre_manual_cleanup(sbi);
854 OBD_FREE(cln_prof, len);
857 lustre_manual_cleanup(sbi);
859 OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
860 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
866 } /* lustre_put_super */
868 #ifdef HAVE_REGISTER_CACHE
869 #include <linux/cache_def.h>
870 #ifdef HAVE_CACHE_RETURN_INT
875 ll_shrink_cache(int priority, unsigned int gfp_mask)
877 struct ll_sb_info *sbi;
880 list_for_each_entry(sbi, &ll_super_blocks, ll_list)
881 count += llap_shrink_cache(sbi, priority);
883 #ifdef HAVE_CACHE_RETURN_INT
888 struct cache_definition ll_cache_definition = {
889 .name = "llap_cache",
890 .shrink = ll_shrink_cache
892 #endif /* HAVE_REGISTER_CACHE */
894 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
896 struct inode *inode = NULL;
897 l_lock(&lock->l_resource->lr_namespace->ns_lock);
898 if (lock->l_ast_data) {
899 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
900 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
901 inode = igrab(lock->l_ast_data);
903 inode = lock->l_ast_data;
904 __LDLM_DEBUG(inode->i_state & I_FREEING ?
905 D_INFO : D_WARNING, lock,
906 "l_ast_data %p is bogus: magic %08x",
907 lock->l_ast_data, lli->lli_inode_magic);
911 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
915 static int null_if_equal(struct ldlm_lock *lock, void *data)
917 if (data == lock->l_ast_data) {
918 lock->l_ast_data = NULL;
920 if (lock->l_req_mode != lock->l_granted_mode)
921 LDLM_ERROR(lock,"clearing inode with ungranted lock");
924 return LDLM_ITER_CONTINUE;
927 void ll_clear_inode(struct inode *inode)
930 struct ll_inode_info *lli = ll_i2info(inode);
931 struct ll_sb_info *sbi = ll_i2sbi(inode);
934 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
935 inode->i_generation, inode);
937 ll_inode2fid(&fid, inode);
938 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
939 mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
942 obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
943 null_if_equal, inode);
946 obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd);
950 if (lli->lli_symlink_name) {
951 OBD_FREE(lli->lli_symlink_name,
952 strlen(lli->lli_symlink_name) + 1);
953 lli->lli_symlink_name = NULL;
955 lli->lli_inode_magic = LLI_INODE_DEAD;
960 /* If this inode has objects allocated to it (lsm != NULL), then the OST
961 * object(s) determine the file size and mtime. Otherwise, the MDS will
962 * keep these values until such a time that objects are allocated for it.
963 * We do the MDS operations first, as it is checking permissions for us.
964 * We don't to the MDS RPC if there is nothing that we want to store there,
965 * otherwise there is no harm in updating mtime/atime on the MDS if we are
966 * going to do an RPC anyways.
968 * If we are doing a truncate, we will send the mtime and ctime updates
969 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
970 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
973 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
975 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
976 struct ll_sb_info *sbi = ll_i2sbi(inode);
977 struct ptlrpc_request *request = NULL;
978 struct mdc_op_data op_data;
979 int ia_valid = attr->ia_valid;
983 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
984 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
986 if (ia_valid & ATTR_SIZE) {
987 if (attr->ia_size > ll_file_maxbytes(inode)) {
988 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
989 attr->ia_size, ll_file_maxbytes(inode));
993 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
996 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
997 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
998 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
1002 /* We mark all of the fields "set" so MDS/OST does not re-set them */
1003 if (attr->ia_valid & ATTR_CTIME) {
1004 attr->ia_ctime = CURRENT_TIME;
1005 attr->ia_valid |= ATTR_CTIME_SET;
1007 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
1008 attr->ia_atime = CURRENT_TIME;
1009 attr->ia_valid |= ATTR_ATIME_SET;
1011 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
1012 attr->ia_mtime = CURRENT_TIME;
1013 attr->ia_valid |= ATTR_MTIME_SET;
1016 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
1017 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
1018 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
1021 attr->ia_valid &= ~ATTR_SIZE;
1023 /* If only OST attributes being set on objects, don't do MDS RPC.
1024 * In that case, we need to check permissions and update the local
1025 * inode ourselves so we can call obdo_from_inode() always. */
1026 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
1027 struct lustre_md md;
1028 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1030 rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
1031 attr, NULL, 0, NULL, 0, &request);
1034 ptlrpc_req_finished(request);
1035 if (rc != -EPERM && rc != -EACCES)
1036 CERROR("mdc_setattr fails: rc = %d\n", rc);
1040 rc = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
1042 ptlrpc_req_finished(request);
1046 /* We call inode_setattr to adjust timestamps, but we first
1047 * clear ATTR_SIZE to avoid invoking vmtruncate.
1049 * NB: ATTR_SIZE will only be set at this point if the size
1050 * resides on the MDS, ie, this file has no objects. */
1051 attr->ia_valid &= ~ATTR_SIZE;
1052 inode_setattr(inode, attr);
1054 ll_update_inode(inode, md.body, md.lsm);
1055 ptlrpc_req_finished(request);
1057 if (!lsm || !S_ISREG(inode->i_mode)) {
1058 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
1062 /* The OST doesn't check permissions, but the alternative is
1063 * a gratuitous RPC to the MDS. We already rely on the client
1064 * to do read/write/truncate permission checks, so is mtime OK?
1066 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
1067 /* from sys_utime() */
1068 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
1069 if (current->fsuid != inode->i_uid &&
1070 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
1073 /* from inode_change_ok() */
1074 if (current->fsuid != inode->i_uid &&
1075 !capable(CAP_FOWNER))
1080 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
1081 inode_setattr(inode, attr);
1084 /* We really need to get our PW lock before we change inode->i_size.
1085 * If we don't we can race with other i_size updaters on our node, like
1086 * ll_file_read. We can also race with i_size propogation to other
1087 * nodes through dirtying and writeback of final cached pages. This
1088 * last one is especially bad for racing o_append users on other
1090 if (ia_valid & ATTR_SIZE) {
1091 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
1093 struct lustre_handle lockh = { 0 };
1094 struct ll_inode_info *lli = ll_i2info(inode);
1095 int err, ast_flags = 0;
1096 /* XXX when we fix the AST intents to pass the discard-range
1097 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
1099 if (attr->ia_size == 0)
1100 ast_flags = LDLM_AST_DISCARD_DATA;
1102 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
1107 down(&lli->lli_size_sem);
1108 lli->lli_size_pid = current->pid;
1109 rc = vmtruncate(inode, attr->ia_size);
1110 // if vmtruncate returned 0, then ll_truncate dropped _size_sem
1112 LASSERT(atomic_read(&lli->lli_size_sem.count) <= 0);
1113 lli->lli_size_pid = 0;
1114 up(&lli->lli_size_sem);
1117 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1119 CERROR("ll_extent_unlock failed: %d\n", err);
1123 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1126 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1127 inode->i_ino, LTIME_S(attr->ia_mtime));
1128 oa.o_id = lsm->lsm_object_id;
1129 oa.o_valid = OBD_MD_FLID;
1130 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
1131 OBD_MD_FLMTIME | OBD_MD_FLCTIME);
1132 rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL);
1134 CERROR("obd_setattr fails: rc=%d\n", rc);
1139 int ll_setattr(struct dentry *de, struct iattr *attr)
1141 LBUG(); /* code is unused, but leave this in case of VFS changes */
1145 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1146 unsigned long max_age)
1148 struct ll_sb_info *sbi = ll_s2sbi(sb);
1149 struct obd_statfs obd_osfs;
1153 rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age);
1155 CERROR("mdc_statfs fails: rc = %d\n", rc);
1159 osfs->os_type = sb->s_magic;
1161 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1162 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1164 rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age);
1166 CERROR("obd_statfs fails: rc = %d\n", rc);
1170 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1171 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1174 osfs->os_blocks = obd_osfs.os_blocks;
1175 osfs->os_bfree = obd_osfs.os_bfree;
1176 osfs->os_bavail = obd_osfs.os_bavail;
1178 /* If we don't have as many objects free on the OST as inodes
1179 * on the MDS, we reduce the total number of inodes to
1180 * compensate, so that the "inodes in use" number is correct.
1182 if (obd_osfs.os_ffree < osfs->os_ffree) {
1183 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1185 osfs->os_ffree = obd_osfs.os_ffree;
1191 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1193 struct obd_statfs osfs;
1196 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1197 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1199 /* For now we will always get up-to-date statfs values, but in the
1200 * future we may allow some amount of caching on the client (e.g.
1201 * from QOS or lprocfs updates). */
1202 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1206 statfs_unpack(sfs, &osfs);
1208 if (sizeof(sfs->f_blocks) == 4) {
1209 while (osfs.os_blocks > ~0UL) {
1212 osfs.os_blocks >>= 1;
1213 osfs.os_bfree >>= 1;
1214 osfs.os_bavail >>= 1;
1218 sfs->f_blocks = osfs.os_blocks;
1219 sfs->f_bfree = osfs.os_bfree;
1220 sfs->f_bavail = osfs.os_bavail;
1225 void ll_update_inode(struct inode *inode, struct mds_body *body,
1226 struct lov_stripe_md *lsm)
1228 struct ll_inode_info *lli = ll_i2info(inode);
1230 LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1232 if (lli->lli_smd == NULL) {
1234 lli->lli_maxbytes = lsm->lsm_maxbytes;
1235 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1236 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1238 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
1239 CERROR("lsm mismatch for inode %ld\n",
1241 CERROR("lli_smd:\n");
1242 dump_lsm(D_ERROR, lli->lli_smd);
1244 dump_lsm(D_ERROR, lsm);
1248 /* bug 2844 - limit i_blksize for broken user-space apps */
1249 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1250 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1251 if (lli->lli_smd != lsm)
1252 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1255 if (body->valid & OBD_MD_FLID)
1256 inode->i_ino = body->ino;
1257 if (body->valid & OBD_MD_FLATIME)
1258 LTIME_S(inode->i_atime) = body->atime;
1259 if (body->valid & OBD_MD_FLMTIME &&
1260 body->mtime > LTIME_S(inode->i_mtime)) {
1261 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to %u\n",
1262 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1263 LTIME_S(inode->i_mtime) = body->mtime;
1265 if (body->valid & OBD_MD_FLCTIME &&
1266 body->ctime > LTIME_S(inode->i_ctime))
1267 LTIME_S(inode->i_ctime) = body->ctime;
1268 if (body->valid & OBD_MD_FLMODE)
1269 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
1270 if (body->valid & OBD_MD_FLTYPE)
1271 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
1272 if (body->valid & OBD_MD_FLUID)
1273 inode->i_uid = body->uid;
1274 if (body->valid & OBD_MD_FLGID)
1275 inode->i_gid = body->gid;
1276 if (body->valid & OBD_MD_FLFLAGS)
1277 inode->i_flags = body->flags;
1278 if (body->valid & OBD_MD_FLNLINK)
1279 inode->i_nlink = body->nlink;
1280 if (body->valid & OBD_MD_FLGENER)
1281 inode->i_generation = body->generation;
1282 if (body->valid & OBD_MD_FLRDEV)
1283 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1284 inode->i_rdev = body->rdev;
1286 inode->i_rdev = old_decode_dev(body->rdev);
1288 if (body->valid & OBD_MD_FLSIZE)
1289 inode->i_size = body->size;
1290 if (body->valid & OBD_MD_FLBLOCKS)
1291 inode->i_blocks = body->blocks;
1293 if (body->valid & OBD_MD_FLSIZE)
1294 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
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;
1325 ll_update_inode(inode, md->body, md->lsm);
1327 /* OIDEBUG(inode); */
1329 if (S_ISREG(inode->i_mode)) {
1330 inode->i_op = &ll_file_inode_operations;
1331 inode->i_fop = &ll_file_operations;
1332 inode->i_mapping->a_ops = &ll_aops;
1334 } else if (S_ISDIR(inode->i_mode)) {
1335 inode->i_op = &ll_dir_inode_operations;
1336 inode->i_fop = &ll_dir_operations;
1337 inode->i_mapping->a_ops = &ll_dir_aops;
1339 } else if (S_ISLNK(inode->i_mode)) {
1340 inode->i_op = &ll_fast_symlink_inode_operations;
1343 inode->i_op = &ll_special_inode_operations;
1345 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1346 init_special_inode(inode, inode->i_mode,
1347 kdev_t_to_nr(inode->i_rdev));
1349 /* initializing backing dev info. */
1350 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1352 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1354 lli->ll_save_ifop = inode->i_fop;
1356 if (S_ISCHR(inode->i_mode))
1357 inode->i_fop = &ll_special_chr_inode_fops;
1358 else if (S_ISBLK(inode->i_mode))
1359 inode->i_fop = &ll_special_blk_inode_fops;
1360 else if (S_ISFIFO(inode->i_mode))
1361 inode->i_fop = &ll_special_fifo_inode_fops;
1362 else if (S_ISSOCK(inode->i_mode))
1363 inode->i_fop = &ll_special_sock_inode_fops;
1368 int ll_iocontrol(struct inode *inode, struct file *file,
1369 unsigned int cmd, unsigned long arg)
1371 struct ll_sb_info *sbi = ll_i2sbi(inode);
1372 struct ptlrpc_request *req = NULL;
1377 case EXT3_IOC_GETFLAGS: {
1379 unsigned long valid = OBD_MD_FLFLAGS;
1380 struct mds_body *body;
1382 ll_inode2fid(&fid, inode);
1383 rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, 0, &req);
1385 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1389 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1391 if (body->flags & S_APPEND)
1392 flags |= EXT3_APPEND_FL;
1393 if (body->flags & S_IMMUTABLE)
1394 flags |= EXT3_IMMUTABLE_FL;
1395 if (body->flags & S_NOATIME)
1396 flags |= EXT3_NOATIME_FL;
1398 ptlrpc_req_finished (req);
1400 RETURN(put_user(flags, (int *)arg));
1402 case EXT3_IOC_SETFLAGS: {
1403 struct mdc_op_data op_data;
1406 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1408 if (get_user(flags, (int *)arg))
1415 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1417 memset(&attr, 0x0, sizeof(attr));
1418 attr.ia_attr_flags = flags;
1419 attr.ia_valid |= ATTR_ATTR_FLAG;
1421 rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
1422 &attr, NULL, 0, NULL, 0, &req);
1424 ptlrpc_req_finished(req);
1425 if (rc != -EPERM && rc != -EACCES)
1426 CERROR("mdc_setattr fails: rc = %d\n", rc);
1430 ptlrpc_req_finished(req);
1432 oa->o_id = lsm->lsm_object_id;
1433 oa->o_flags = flags;
1434 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS;
1436 rc = obd_setattr(sbi->ll_osc_exp, oa, lsm, NULL);
1439 if (rc != -EPERM && rc != -EACCES)
1440 CERROR("mdc_setattr fails: rc = %d\n", rc);
1444 if (flags & EXT3_APPEND_FL)
1445 inode->i_flags |= S_APPEND;
1447 inode->i_flags &= ~S_APPEND;
1448 if (flags & EXT3_IMMUTABLE_FL)
1449 inode->i_flags |= S_IMMUTABLE;
1451 inode->i_flags &= ~S_IMMUTABLE;
1452 if (flags & EXT3_NOATIME_FL)
1453 inode->i_flags |= S_NOATIME;
1455 inode->i_flags &= ~S_NOATIME;
1466 void ll_umount_begin(struct super_block *sb)
1468 struct ll_sb_info *sbi = ll_s2sbi(sb);
1469 struct obd_device *obd;
1470 struct obd_ioctl_data ioc_data = { 0 };
1472 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1474 obd = class_exp2obd(sbi->ll_mdc_exp);
1476 CERROR("Invalid MDC connection handle "LPX64"\n",
1477 sbi->ll_mdc_exp->exp_handle.h_cookie);
1481 obd->obd_no_recov = 1;
1482 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data,
1485 obd = class_exp2obd(sbi->ll_osc_exp);
1487 CERROR("Invalid LOV connection handle "LPX64"\n",
1488 sbi->ll_osc_exp->exp_handle.h_cookie);
1493 obd->obd_no_recov = 1;
1494 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data,
1497 /* Really, we'd like to wait until there are no requests outstanding,
1498 * and then continue. For now, we just invalidate the requests,
1499 * schedule, and hope.
1506 int lustre_remount_fs(struct super_block *sb, int *flags, char *data)
1508 struct ll_sb_info *sbi = ll_s2sbi(sb);
1512 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
1513 read_only = *flags & MS_RDONLY;
1514 err = obd_set_info(sbi->ll_mdc_exp, strlen("read-only"),
1515 "read-only", sizeof(read_only), &read_only);
1517 CERROR("Failed to change the read-only flag during "
1518 "remount: %d\n", err);
1525 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
1526 struct ptlrpc_request *req, int offset,struct super_block *sb)
1528 struct lustre_md md;
1531 rc = mdc_req2lustre_md(req, offset, exp, &md);
1536 ll_update_inode(*inode, md.body, md.lsm);
1539 *inode = ll_iget(sb, md.body->ino, &md);
1540 if (*inode == NULL || is_bad_inode(*inode)) {
1541 /* free the lsm if we allocated one above */
1543 obd_free_memmd(exp, &md.lsm);
1545 CERROR("new_inode -fatal: rc %d\n", rc);
1552 char *llap_origins[] = {
1553 [LLAP_ORIGIN_UNKNOWN] = "--",
1554 [LLAP_ORIGIN_READPAGE] = "rp",
1555 [LLAP_ORIGIN_READAHEAD] = "ra",
1556 [LLAP_ORIGIN_COMMIT_WRITE] = "cw",
1557 [LLAP_ORIGIN_WRITEPAGE] = "wp",
1560 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
1561 struct list_head *list)
1563 struct ll_async_page *llap;
1564 struct list_head *pos;
1566 list_for_each(pos, list) {
1567 if (pos == &sbi->ll_pglist)
1569 llap = list_entry(pos, struct ll_async_page, llap_pglist_item);
1570 if (llap->llap_page == NULL)