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_ver.h>
34 #include <linux/lustre_dlm.h>
35 #include <linux/lprocfs_status.h>
36 #include <linux/lustre_disk.h>
37 #include "llite_internal.h"
39 kmem_cache_t *ll_file_data_slab;
41 LIST_HEAD(ll_super_blocks);
42 spinlock_t ll_sb_lock = SPIN_LOCK_UNLOCKED;
44 extern struct address_space_operations ll_aops;
45 extern struct address_space_operations ll_dir_aops;
48 #define log2(n) ffz(~(n))
51 /* We need to have some extra twiddling here because some systems have
52 * no random state when they start up. */
54 lustre_generate_random_uuid(class_uuid_t uuid)
60 LASSERT(sizeof(class_uuid_t) % sizeof(*i) == 0);
66 generate_random_uuid(uuid);
68 for (i = (int *)uuid; (char *)i < (char *)uuid + sizeof(class_uuid_t); i++) {
70 j = ((j << 8) & 0xffffff00) | ((j >> 24) & 0x000000ff);
71 k = ((k >> 8) & 0x00ffffff) | ((k << 24) & 0xff000000);
77 struct ll_sb_info *ll_init_sbi(void)
79 struct ll_sb_info *sbi = NULL;
83 OBD_ALLOC(sbi, sizeof(*sbi));
87 spin_lock_init(&sbi->ll_lock);
88 spin_lock_init(&sbi->ll_lco.lco_lock);
89 INIT_LIST_HEAD(&sbi->ll_pglist);
90 sbi->ll_pglist_gen = 0;
91 if (num_physpages >> (20 - PAGE_SHIFT) < 512)
92 sbi->ll_async_page_max = num_physpages / 2;
94 sbi->ll_async_page_max = (num_physpages / 4) * 3;
95 sbi->ll_ra_info.ra_max_pages = min(num_physpages / 8,
96 SBI_DEFAULT_READAHEAD_MAX);
98 INIT_LIST_HEAD(&sbi->ll_conn_chain);
99 INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
101 lustre_generate_random_uuid(uuid);
102 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
103 CDEBUG(D_HA, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
105 spin_lock(&ll_sb_lock);
106 list_add_tail(&sbi->ll_list, &ll_super_blocks);
107 spin_unlock(&ll_sb_lock);
109 INIT_LIST_HEAD(&sbi->ll_deathrow);
110 spin_lock_init(&sbi->ll_deathrow_lock);
114 void ll_free_sbi(struct super_block *sb)
116 struct ll_sb_info *sbi = ll_s2sbi(sb);
120 spin_lock(&ll_sb_lock);
121 list_del(&sbi->ll_list);
122 spin_unlock(&ll_sb_lock);
123 OBD_FREE(sbi, sizeof(*sbi));
128 static struct dentry_operations ll_d_root_ops = {
129 .d_compare = ll_dcompare,
132 int client_common_fill_super(struct super_block *sb, char *mdc, char *osc)
134 struct inode *root = 0;
135 struct ll_sb_info *sbi = ll_s2sbi(sb);
136 struct obd_device *obd;
137 struct ll_fid rootfid;
138 struct obd_statfs osfs;
139 struct ptlrpc_request *request = NULL;
140 struct lustre_handle osc_conn = {0, };
141 struct lustre_handle mdc_conn = {0, };
143 struct obd_connect_data *data = NULL;
147 obd = class_name2obd(mdc);
149 CERROR("MDC %s: not setup or attached\n", mdc);
153 OBD_ALLOC(data, sizeof(*data));
157 if (proc_lustre_fs_root) {
158 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
161 CERROR("could not register mount in /proc/lustre");
164 /* indicate that inodebits locking is supported by this client */
165 data->ocd_connect_flags |= OBD_CONNECT_IBITS;
166 data->ocd_ibits_known = MDS_INODELOCK_FULL;
168 if (sb->s_flags & MS_RDONLY)
169 data->ocd_connect_flags |= OBD_CONNECT_RDONLY;
170 if (sbi->ll_flags & LL_SBI_USER_XATTR)
171 data->ocd_connect_flags |= OBD_CONNECT_XATTR;
172 data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_JOIN;
174 if (sbi->ll_flags & LL_SBI_FLOCK) {
175 sbi->ll_fop = &ll_file_operations_flock;
177 sbi->ll_fop = &ll_file_operations;
180 data->ocd_connect_flags |= OBD_CONNECT_VERSION;
181 data->ocd_version = LUSTRE_VERSION_CODE;
183 err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, data);
185 CERROR("An MDT (mdc %s) is performing recovery, of which this"
186 " client is not a part. Please wait for recovery to "
187 "complete, abort, or time out.\n", mdc);
190 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
193 sbi->ll_mdc_exp = class_conn2export(&mdc_conn);
195 err = obd_statfs(obd, &osfs, jiffies - HZ);
199 /* async connect is surely finished by now */
200 *data = class_exp2cliimp(sbi->ll_mdc_exp)->imp_connect_data;
202 LASSERT(osfs.os_bsize);
203 sb->s_blocksize = osfs.os_bsize;
204 sb->s_blocksize_bits = log2(osfs.os_bsize);
205 sb->s_magic = LL_SUPER_MAGIC;
206 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
207 sbi->ll_namelen = osfs.os_namelen;
209 if ((sbi->ll_flags & LL_SBI_USER_XATTR) &&
210 !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) {
211 LCONSOLE_INFO("Disabling user_xattr feature because "
212 "it is not supported on the server\n");
213 sbi->ll_flags &= ~LL_SBI_USER_XATTR;
216 if (data->ocd_connect_flags & OBD_CONNECT_ACL) {
218 sb->s_flags |= MS_POSIXACL;
220 sbi->ll_flags |= LL_SBI_ACL;
222 sbi->ll_flags &= ~LL_SBI_ACL;
224 if (data->ocd_connect_flags & OBD_CONNECT_JOIN)
225 sbi->ll_flags |= LL_SBI_JOIN;
227 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
228 /* We set sb->s_dev equal on all lustre clients in order to support
229 * NFS export clustering. NFSD requires that the FSID be the same
231 /* s_dev is also used in lt_compare() to compare two fs, but that is
232 * only a node-local comparison. */
233 sb->s_dev = get_uuid2int(sbi2mdc(sbi)->cl_import->imp_target_uuid.uuid,
234 strlen(sbi2mdc(sbi)->cl_import->imp_target_uuid.uuid));
237 obd = class_name2obd(osc);
239 CERROR("OSC %s: not setup or attached\n", osc);
243 data->ocd_connect_flags =
244 OBD_CONNECT_GRANT|OBD_CONNECT_VERSION|OBD_CONNECT_REQPORTAL;
246 CDEBUG(D_RPCTRACE, "ocd_connect_flags: "LPX64" ocd_version: %d "
247 "ocd_grant: %d\n", data->ocd_connect_flags,
248 data->ocd_version, data->ocd_grant);
250 obd->obd_upcall.onu_owner = &sbi->ll_lco;
251 obd->obd_upcall.onu_upcall = ll_ocd_update;
253 err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, data);
255 CERROR("An OST (osc %s) is performing recovery, of which this"
256 " client is not a part. Please wait for recovery to "
257 "complete, abort, or time out.\n", osc);
260 CERROR("cannot connect to %s: rc = %d\n", osc, err);
263 sbi->ll_osc_exp = class_conn2export(&osc_conn);
264 spin_lock(&sbi->ll_lco.lco_lock);
265 sbi->ll_lco.lco_flags = data->ocd_connect_flags;
266 spin_unlock(&sbi->ll_lco.lco_lock);
268 mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
270 if (!ll_async_page_slab) {
271 ll_async_page_slab_size =
272 size_round(sizeof(struct ll_async_page)) +
273 obd_prep_async_page(sbi->ll_osc_exp, NULL, NULL, NULL,
274 0, NULL, NULL, NULL);
275 ll_async_page_slab = kmem_cache_create("ll_async_page",
276 ll_async_page_slab_size,
278 if (!ll_async_page_slab)
279 GOTO(out_osc, -ENOMEM);
282 err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid);
284 CERROR("cannot mds_connect: rc = %d\n", err);
287 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
288 sbi->ll_rootino = rootfid.id;
290 sb->s_op = &lustre_super_operations;
293 * XXX: move this to after cbd setup? */
294 err = mdc_getattr(sbi->ll_mdc_exp, &rootfid,
295 OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS |
296 (sbi->ll_flags & LL_SBI_ACL ? OBD_MD_FLACL : 0),
299 CERROR("mdc_getattr failed for root: rc = %d\n", err);
303 err = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
305 CERROR("failed to understand root inode md: rc = %d\n",err);
306 ptlrpc_req_finished (request);
310 LASSERT(sbi->ll_rootino != 0);
311 root = ll_iget(sb, sbi->ll_rootino, &md);
313 ptlrpc_req_finished(request);
315 if (root == NULL || is_bad_inode(root)) {
316 mdc_free_lustre_md(sbi->ll_osc_exp, &md);
317 CERROR("lustre_lite: bad iget4 for root\n");
318 GOTO(out_root, err = -EBADF);
321 err = ll_close_thread_start(&sbi->ll_lcq);
323 CERROR("cannot start close thread: rc %d\n", err);
327 /* making vm readahead 0 for 2.4.x. In the case of 2.6.x,
328 backing dev info assigned to inode mapping is used for
329 determining maximal readahead. */
330 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
331 !defined(KERNEL_HAS_AS_MAX_READAHEAD)
332 /* bug 2805 - set VM readahead to zero */
333 vm_max_readahead = vm_min_readahead = 0;
336 sb->s_root = d_alloc_root(root);
338 OBD_FREE(data, sizeof(*data));
339 sb->s_root->d_op = &ll_d_root_ops;
346 obd_disconnect(sbi->ll_osc_exp);
348 obd_disconnect(sbi->ll_mdc_exp);
351 OBD_FREE(data, sizeof(*data));
352 lprocfs_unregister_mountpoint(sbi);
356 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
360 *lmmsize = obd_size_diskmd(sbi->ll_osc_exp, NULL);
362 rc = obd_get_info(sbi->ll_mdc_exp, strlen("max_easize"), "max_easize",
365 CERROR("Get max mdsize error rc %d \n", rc);
370 void ll_dump_inode(struct inode *inode)
372 struct list_head *tmp;
373 int dentry_count = 0;
375 LASSERT(inode != NULL);
377 list_for_each(tmp, &inode->i_dentry)
380 CERROR("inode %p dump: dev=%s ino=%lu mode=%o count=%u, %d dentries\n",
381 inode, ll_i2mdcexp(inode)->exp_obd->obd_name, inode->i_ino,
382 inode->i_mode, atomic_read(&inode->i_count), dentry_count);
385 void lustre_dump_dentry(struct dentry *dentry, int recur)
387 struct list_head *tmp;
390 LASSERT(dentry != NULL);
392 list_for_each(tmp, &dentry->d_subdirs)
395 CERROR("dentry %p dump: name=%.*s parent=%.*s (%p), inode=%p, count=%u,"
396 " flags=0x%x, fsdata=%p, %d subdirs\n", dentry,
397 dentry->d_name.len, dentry->d_name.name,
398 dentry->d_parent->d_name.len, dentry->d_parent->d_name.name,
399 dentry->d_parent, dentry->d_inode, atomic_read(&dentry->d_count),
400 dentry->d_flags, dentry->d_fsdata, subdirs);
401 if (dentry->d_inode != NULL)
402 ll_dump_inode(dentry->d_inode);
407 list_for_each(tmp, &dentry->d_subdirs) {
408 struct dentry *d = list_entry(tmp, struct dentry, d_child);
409 lustre_dump_dentry(d, recur - 1);
413 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
414 void lustre_throw_orphan_dentries(struct super_block *sb)
416 struct hlist_node *tmp, *next;
417 struct ll_sb_info *sbi = ll_s2sbi(sb);
419 /* Do this to get rid of orphaned dentries. That is not really trw. */
420 hlist_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
421 struct dentry *dentry = hlist_entry(tmp, struct dentry, d_hash);
422 CWARN("found orphan dentry %.*s (%p->%p) at unmount, dumping "
423 "before and after shrink_dcache_parent\n",
424 dentry->d_name.len, dentry->d_name.name, dentry, next);
425 lustre_dump_dentry(dentry, 1);
426 shrink_dcache_parent(dentry);
427 lustre_dump_dentry(dentry, 1);
431 #define lustre_throw_orphan_dentries(sb)
434 static void prune_deathrow(struct ll_sb_info *sbi, int try)
436 LIST_HEAD(throw_away);
441 locked = spin_trylock(&sbi->ll_deathrow_lock);
443 spin_lock(&sbi->ll_deathrow_lock);
452 list_splice_init(&sbi->ll_deathrow, &throw_away);
453 spin_unlock(&sbi->ll_deathrow_lock);
455 while (!list_empty(&throw_away)) {
456 struct ll_inode_info *lli;
459 lli = list_entry(throw_away.next, struct ll_inode_info,
461 list_del_init(&lli->lli_dead_list);
463 inode = ll_info2i(lli);
464 d_prune_aliases(inode);
466 CDEBUG(D_INODE, "prune duplicate inode %p inum %lu count %u\n",
467 inode, inode->i_ino, atomic_read(&inode->i_count));
473 void client_common_put_super(struct super_block *sb)
475 struct ll_sb_info *sbi = ll_s2sbi(sb);
478 ll_close_thread_shutdown(sbi->ll_lcq);
480 /* destroy inodes in deathrow */
481 prune_deathrow(sbi, 0);
483 list_del(&sbi->ll_conn_chain);
484 obd_disconnect(sbi->ll_osc_exp);
486 lprocfs_unregister_mountpoint(sbi);
487 if (sbi->ll_proc_root) {
488 lprocfs_remove(sbi->ll_proc_root);
489 sbi->ll_proc_root = NULL;
492 obd_disconnect(sbi->ll_mdc_exp);
494 lustre_throw_orphan_dentries(sb);
499 char *ll_read_opt(const char *opt, char *data)
505 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
506 if (strncmp(opt, data, strlen(opt)))
508 if ((value = strchr(data, '=')) == NULL)
512 OBD_ALLOC(retval, strlen(value) + 1);
514 CERROR("out of memory!\n");
518 memcpy(retval, value, strlen(value)+1);
519 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
523 int ll_set_opt(const char *opt, char *data, int fl)
527 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
528 if (strncmp(opt, data, strlen(opt)) != 0)
534 /* non-client-specific mount options are parsed in lmd_parse */
535 void ll_options(char *options, int *flags)
539 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
540 char *opt_ptr = options;
549 CDEBUG(D_CONFIG, "Parsing opts %s\n", options);
550 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
551 for (this_char = strtok (options, ",");
553 this_char = strtok (NULL, ","))
555 while ((this_char = strsep (&opt_ptr, ",")) != NULL)
558 CDEBUG(D_SUPER, "this_char %s\n", this_char);
559 tmp = ll_set_opt("nolock", this_char, LL_SBI_NOLCK);
564 tmp = ll_set_opt("flock", this_char, LL_SBI_FLOCK);
569 tmp = ll_set_opt("noflock", this_char, LL_SBI_FLOCK);
574 tmp = ll_set_opt("user_xattr", this_char, LL_SBI_USER_XATTR);
579 tmp = ll_set_opt("nouser_xattr", this_char, LL_SBI_USER_XATTR);
584 tmp = ll_set_opt("acl", this_char, LL_SBI_ACL);
586 /* Ignore deprecated mount option. The client will
587 * always try to mount with ACL support, whether this
588 * is used depends on whether server supports it. */
591 tmp = ll_set_opt("noacl", this_char, LL_SBI_ACL);
596 CERROR("flags %#x\n", *flags);
601 void ll_lli_init(struct ll_inode_info *lli)
603 sema_init(&lli->lli_open_sem, 1);
604 sema_init(&lli->lli_size_sem, 1);
606 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
607 spin_lock_init(&lli->lli_lock);
608 INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
609 lli->lli_inode_magic = LLI_INODE_MAGIC;
610 INIT_LIST_HEAD(&lli->lli_dead_list);
613 int ll_fill_super(struct super_block *sb)
615 struct lustre_profile *lprof;
616 struct lustre_sb_info *lsi = s2lsi(sb);
617 struct ll_sb_info *sbi;
620 char *profilenm = get_profile_name(sb);
621 struct config_llog_instance cfg;
622 char ll_instance[sizeof(sb) * 2 + 1];
626 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
628 /* client additional sb info */
629 lsi->lsi_llsbi = sbi = ll_init_sbi();
633 ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags);
635 /* Generate a string unique to this super, in case some joker tries
636 to mount the same fs at two mount points.
637 Use the address of the super itself.*/
638 sprintf(ll_instance, "%p", sb);
639 cfg.cfg_instance = ll_instance;
640 cfg.cfg_uuid = lsi->lsi_llsbi->ll_sb_uuid;
641 cfg.cfg_last_idx = 0;
643 /* set up client obds */
644 err = lustre_process_log(sb, profilenm, &cfg);
646 CERROR("Unable to process log: %d\n", err);
650 lprof = class_get_profile(profilenm);
652 CERROR("No profile found: %s\n", profilenm);
653 GOTO(out_free, err = -EINVAL);
655 CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
656 lprof->lp_mdc, lprof->lp_osc);
658 OBD_ALLOC(osc, strlen(lprof->lp_osc) +
659 strlen(ll_instance) + 2);
661 GOTO(out_free, err = -ENOMEM);
662 sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance);
664 OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
665 strlen(ll_instance) + 2);
667 GOTO(out_free, err = -ENOMEM);
668 sprintf(mdc, "%s-%s", lprof->lp_mdc, ll_instance);
670 /* connections, registrations, sb setup */
671 err = client_common_fill_super(sb, mdc, osc);
675 OBD_FREE(mdc, strlen(mdc) + 1);
677 OBD_FREE(osc, strlen(osc) + 1);
679 struct obd_device *obd;
681 /* like client_put_super below */
682 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next))
684 class_manual_cleanup(obd);
686 class_del_profile(profilenm);
688 lsi->lsi_llsbi = NULL;
691 } /* ll_fill_super */
694 void ll_put_super(struct super_block *sb)
696 struct config_llog_instance cfg;
697 char ll_instance[sizeof(sb) * 2 + 1];
698 struct obd_device *obd;
699 struct lustre_sb_info *lsi = s2lsi(sb);
700 struct ll_sb_info *sbi = ll_s2sbi(sb);
701 char *profilenm = get_profile_name(sb);
705 CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm);
707 sprintf(ll_instance, "%p", sb);
708 cfg.cfg_instance = ll_instance;
709 lustre_end_log(sb, NULL, &cfg);
711 obd = class_exp2obd(sbi->ll_mdc_exp);
714 int force = obd->obd_no_recov;
715 /* We need to set force before the lov_disconnect in
716 lustre_common_put_super, since l_d cleans up osc's as well. */
717 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next))
719 obd->obd_force = force;
723 client_common_put_super(sb);
725 while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) {
726 class_manual_cleanup(obd);
730 class_del_profile(profilenm);
733 lsi->lsi_llsbi = NULL;
735 lustre_common_put_super(sb);
738 } /* client_put_super */
740 #ifdef HAVE_REGISTER_CACHE
741 #include <linux/cache_def.h>
742 #ifdef HAVE_CACHE_RETURN_INT
747 ll_shrink_cache(int priority, unsigned int gfp_mask)
749 struct ll_sb_info *sbi;
752 list_for_each_entry(sbi, &ll_super_blocks, ll_list)
753 count += llap_shrink_cache(sbi, priority);
755 #ifdef HAVE_CACHE_RETURN_INT
760 struct cache_definition ll_cache_definition = {
761 .name = "llap_cache",
762 .shrink = ll_shrink_cache
764 #endif /* HAVE_REGISTER_CACHE */
766 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
768 struct inode *inode = NULL;
769 l_lock(&lock->l_resource->lr_namespace->ns_lock);
770 if (lock->l_ast_data) {
771 struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
772 if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
773 inode = igrab(lock->l_ast_data);
775 inode = lock->l_ast_data;
776 __LDLM_DEBUG(inode->i_state & I_FREEING ?
777 D_INFO : D_WARNING, lock,
778 "l_ast_data %p is bogus: magic %08x",
779 lock->l_ast_data, lli->lli_inode_magic);
783 l_unlock(&lock->l_resource->lr_namespace->ns_lock);
787 static int null_if_equal(struct ldlm_lock *lock, void *data)
789 if (data == lock->l_ast_data) {
790 lock->l_ast_data = NULL;
792 if (lock->l_req_mode != lock->l_granted_mode)
793 LDLM_ERROR(lock,"clearing inode with ungranted lock");
796 return LDLM_ITER_CONTINUE;
799 void ll_clear_inode(struct inode *inode)
802 struct ll_inode_info *lli = ll_i2info(inode);
803 struct ll_sb_info *sbi = ll_i2sbi(inode);
806 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
807 inode->i_generation, inode);
809 ll_inode2fid(&fid, inode);
810 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
811 mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
814 obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
815 null_if_equal, inode);
817 obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd);
821 if (lli->lli_symlink_name) {
822 OBD_FREE(lli->lli_symlink_name,
823 strlen(lli->lli_symlink_name) + 1);
824 lli->lli_symlink_name = NULL;
827 #ifdef CONFIG_FS_POSIX_ACL
828 if (lli->lli_posix_acl) {
829 LASSERT(atomic_read(&lli->lli_posix_acl->a_refcount) == 1);
830 posix_acl_release(lli->lli_posix_acl);
831 lli->lli_posix_acl = NULL;
835 lli->lli_inode_magic = LLI_INODE_DEAD;
837 spin_lock(&sbi->ll_deathrow_lock);
838 list_del_init(&lli->lli_dead_list);
839 spin_unlock(&sbi->ll_deathrow_lock);
844 /* If this inode has objects allocated to it (lsm != NULL), then the OST
845 * object(s) determine the file size and mtime. Otherwise, the MDS will
846 * keep these values until such a time that objects are allocated for it.
847 * We do the MDS operations first, as it is checking permissions for us.
848 * We don't to the MDS RPC if there is nothing that we want to store there,
849 * otherwise there is no harm in updating mtime/atime on the MDS if we are
850 * going to do an RPC anyways.
852 * If we are doing a truncate, we will send the mtime and ctime updates
853 * to the OST with the punch RPC, otherwise we do an explicit setattr RPC.
854 * I don't believe it is possible to get e.g. ATTR_MTIME_SET and ATTR_SIZE
857 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
859 struct ll_inode_info *lli = ll_i2info(inode);
860 struct lov_stripe_md *lsm = lli->lli_smd;
861 struct ll_sb_info *sbi = ll_i2sbi(inode);
862 struct ptlrpc_request *request = NULL;
863 struct mdc_op_data op_data;
864 int ia_valid = attr->ia_valid;
868 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu valid %x\n", inode->i_ino,
870 lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_SETATTR);
872 if (ia_valid & ATTR_SIZE) {
873 if (attr->ia_size > ll_file_maxbytes(inode)) {
874 CDEBUG(D_INODE, "file too large %llu > "LPU64"\n",
875 attr->ia_size, ll_file_maxbytes(inode));
879 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
882 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
883 if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
884 if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
888 /* We mark all of the fields "set" so MDS/OST does not re-set them */
889 if (attr->ia_valid & ATTR_CTIME) {
890 attr->ia_ctime = CURRENT_TIME;
891 attr->ia_valid |= ATTR_CTIME_SET;
893 if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) {
894 attr->ia_atime = CURRENT_TIME;
895 attr->ia_valid |= ATTR_ATIME_SET;
897 if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) {
898 attr->ia_mtime = CURRENT_TIME;
899 attr->ia_valid |= ATTR_MTIME_SET;
902 if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
903 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
904 LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
908 /* NB: ATTR_SIZE will only be set after this point if the size
909 * resides on the MDS, ie, this file has no objects. */
911 attr->ia_valid &= ~ATTR_SIZE;
913 /* If only OST attributes being set on objects, don't do MDS RPC.
914 * In that case, we need to check permissions and update the local
915 * inode ourselves so we can call obdo_from_inode() always. */
916 if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) {
918 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
920 rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
921 attr, NULL, 0, NULL, 0, &request);
924 ptlrpc_req_finished(request);
925 if (rc != -EPERM && rc != -EACCES)
926 CERROR("mdc_setattr fails: rc = %d\n", rc);
930 rc = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md);
932 ptlrpc_req_finished(request);
936 /* We call inode_setattr to adjust timestamps.
937 * If there is at least some data in file, we cleared ATTR_SIZE
938 * above to avoid invoking vmtruncate, otherwise it is important
939 * to call vmtruncate in inode_setattr to update inode->i_size
941 rc = inode_setattr(inode, attr);
943 ll_update_inode(inode, &md);
944 ptlrpc_req_finished(request);
946 if (!lsm || !S_ISREG(inode->i_mode)) {
947 CDEBUG(D_INODE, "no lsm: not setting attrs on OST\n");
951 /* The OST doesn't check permissions, but the alternative is
952 * a gratuitous RPC to the MDS. We already rely on the client
953 * to do read/write/truncate permission checks, so is mtime OK?
955 if (ia_valid & (ATTR_MTIME | ATTR_ATIME)) {
956 /* from sys_utime() */
957 if (!(ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))) {
958 if (current->fsuid != inode->i_uid &&
959 (rc=ll_permission(inode,MAY_WRITE,NULL))!=0)
962 /* from inode_change_ok() */
963 if (current->fsuid != inode->i_uid &&
964 !capable(CAP_FOWNER))
969 /* Won't invoke vmtruncate, as we already cleared ATTR_SIZE */
970 rc = inode_setattr(inode, attr);
973 /* We really need to get our PW lock before we change inode->i_size.
974 * If we don't we can race with other i_size updaters on our node, like
975 * ll_file_read. We can also race with i_size propogation to other
976 * nodes through dirtying and writeback of final cached pages. This
977 * last one is especially bad for racing o_append users on other
979 if (ia_valid & ATTR_SIZE) {
980 ldlm_policy_data_t policy = { .l_extent = {attr->ia_size,
982 struct lustre_handle lockh = { 0 };
983 int err, ast_flags = 0;
984 /* XXX when we fix the AST intents to pass the discard-range
985 * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
987 if (attr->ia_size == 0)
988 ast_flags = LDLM_AST_DISCARD_DATA;
991 UP_WRITE_I_ALLOC_SEM(inode);
992 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh,
994 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
995 DOWN_WRITE_I_ALLOC_SEM(inode);
999 DOWN_WRITE_I_ALLOC_SEM(inode);
1004 /* Only ll_inode_size_lock is taken at this level.
1005 * lov_stripe_lock() is grabbed by ll_truncate() only over
1006 * call to obd_adjust_kms(). If vmtruncate returns 0, then
1007 * ll_truncate dropped ll_inode_size_lock() */
1008 ll_inode_size_lock(inode, 0);
1009 rc = vmtruncate(inode, attr->ia_size);
1011 LASSERT(atomic_read(&lli->lli_size_sem.count) <= 0);
1012 ll_inode_size_unlock(inode, 0);
1015 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
1017 CERROR("ll_extent_unlock failed: %d\n", err);
1021 } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
1025 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
1026 inode->i_ino, LTIME_S(attr->ia_mtime));
1028 oa.o_id = lsm->lsm_object_id;
1029 oa.o_valid = OBD_MD_FLID;
1031 flags = OBD_MD_FLTYPE | OBD_MD_FLATIME |
1032 OBD_MD_FLMTIME | OBD_MD_FLCTIME |
1033 OBD_MD_FLFID | OBD_MD_FLGENER;
1035 obdo_from_inode(&oa, inode, flags);
1036 rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL);
1038 CERROR("obd_setattr fails: rc=%d\n", rc);
1043 int ll_setattr(struct dentry *de, struct iattr *attr)
1045 LBUG(); /* code is unused, but leave this in case of VFS changes */
1049 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
1050 unsigned long max_age)
1052 struct ll_sb_info *sbi = ll_s2sbi(sb);
1053 struct obd_statfs obd_osfs;
1057 rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age);
1059 CERROR("mdc_statfs fails: rc = %d\n", rc);
1063 osfs->os_type = sb->s_magic;
1065 CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1066 osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
1068 rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age);
1070 CERROR("obd_statfs fails: rc = %d\n", rc);
1074 CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
1075 obd_osfs.os_bavail, obd_osfs.os_blocks, obd_osfs.os_ffree,
1078 osfs->os_blocks = obd_osfs.os_blocks;
1079 osfs->os_bfree = obd_osfs.os_bfree;
1080 osfs->os_bavail = obd_osfs.os_bavail;
1082 /* If we don't have as many objects free on the OST as inodes
1083 * on the MDS, we reduce the total number of inodes to
1084 * compensate, so that the "inodes in use" number is correct.
1086 if (obd_osfs.os_ffree < osfs->os_ffree) {
1087 osfs->os_files = (osfs->os_files - osfs->os_ffree) +
1089 osfs->os_ffree = obd_osfs.os_ffree;
1095 int ll_statfs(struct super_block *sb, struct kstatfs *sfs)
1097 struct obd_statfs osfs;
1100 CDEBUG(D_VFSTRACE, "VFS Op:\n");
1101 lprocfs_counter_incr(ll_s2sbi(sb)->ll_stats, LPROC_LL_STAFS);
1103 /* For now we will always get up-to-date statfs values, but in the
1104 * future we may allow some amount of caching on the client (e.g.
1105 * from QOS or lprocfs updates). */
1106 rc = ll_statfs_internal(sb, &osfs, jiffies - 1);
1110 statfs_unpack(sfs, &osfs);
1112 if (sizeof(sfs->f_blocks) == 4) {
1113 while (osfs.os_blocks > ~0UL) {
1116 osfs.os_blocks >>= 1;
1117 osfs.os_bfree >>= 1;
1118 osfs.os_bavail >>= 1;
1122 sfs->f_blocks = osfs.os_blocks;
1123 sfs->f_bfree = osfs.os_bfree;
1124 sfs->f_bavail = osfs.os_bavail;
1129 void ll_inode_size_lock(struct inode *inode, int lock_lsm)
1131 struct ll_inode_info *lli;
1132 struct lov_stripe_md *lsm;
1134 lli = ll_i2info(inode);
1135 LASSERT(lli->lli_size_sem_owner != current);
1136 down(&lli->lli_size_sem);
1137 LASSERT(lli->lli_size_sem_owner == NULL);
1138 lli->lli_size_sem_owner = current;
1140 LASSERTF(lsm != NULL || lock_lsm == 0, "lsm %p, lock_lsm %d\n",
1143 lov_stripe_lock(lsm);
1146 void ll_inode_size_unlock(struct inode *inode, int unlock_lsm)
1148 struct ll_inode_info *lli;
1149 struct lov_stripe_md *lsm;
1151 lli = ll_i2info(inode);
1153 LASSERTF(lsm != NULL || unlock_lsm == 0, "lsm %p, lock_lsm %d\n",
1156 lov_stripe_unlock(lsm);
1157 LASSERT(lli->lli_size_sem_owner == current);
1158 lli->lli_size_sem_owner = NULL;
1159 up(&lli->lli_size_sem);
1162 static void ll_replace_lsm(struct inode *inode, struct lov_stripe_md *lsm)
1164 struct ll_inode_info *lli = ll_i2info(inode);
1166 dump_lsm(D_INODE, lsm);
1167 dump_lsm(D_INODE, lli->lli_smd);
1168 LASSERTF(lsm->lsm_magic == LOV_MAGIC_JOIN,
1169 "lsm must be joined lsm %p\n", lsm);
1170 obd_free_memmd(ll_i2obdexp(inode), &lli->lli_smd);
1171 CDEBUG(D_INODE, "replace lsm %p to lli_smd %p for inode %lu%u(%p)\n",
1172 lsm, lli->lli_smd, inode->i_ino, inode->i_generation, inode);
1174 lli->lli_maxbytes = lsm->lsm_maxbytes;
1175 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1176 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1179 void ll_update_inode(struct inode *inode, struct lustre_md *md)
1181 struct ll_inode_info *lli = ll_i2info(inode);
1182 struct mds_body *body = md->body;
1183 struct lov_stripe_md *lsm = md->lsm;
1185 LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
1187 if (lli->lli_smd == NULL) {
1188 if (lsm->lsm_magic != LOV_MAGIC &&
1189 lsm->lsm_magic != LOV_MAGIC_JOIN) {
1190 dump_lsm(D_ERROR, lsm);
1193 CDEBUG(D_INODE, "adding lsm %p to inode %lu/%u(%p)\n",
1194 lsm, inode->i_ino, inode->i_generation, inode);
1195 /* ll_inode_size_lock() requires it is only called
1196 * with lli_smd != NULL or lock_lsm == 0 or we can
1197 * race between lock/unlock. bug 9547 */
1199 lli->lli_maxbytes = lsm->lsm_maxbytes;
1200 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
1201 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
1203 if (lli->lli_smd->lsm_magic == lsm->lsm_magic &&
1204 lli->lli_smd->lsm_stripe_count ==
1205 lsm->lsm_stripe_count) {
1206 if (lov_stripe_md_cmp(lli->lli_smd, lsm)) {
1207 CERROR("lsm mismatch for inode %ld\n",
1209 CERROR("lli_smd:\n");
1210 dump_lsm(D_ERROR, lli->lli_smd);
1212 dump_lsm(D_ERROR, lsm);
1216 ll_replace_lsm(inode, lsm);
1218 /* bug 2844 - limit i_blksize for broken user-space apps */
1219 LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
1220 inode->i_blksize = min(lsm->lsm_xfersize, LL_MAX_BLKSIZE);
1221 if (lli->lli_smd != lsm)
1222 obd_free_memmd(ll_i2obdexp(inode), &lsm);
1224 inode->i_blksize = max(inode->i_blksize,
1225 inode->i_sb->s_blocksize);
1228 #ifdef CONFIG_FS_POSIX_ACL
1229 LASSERT(!md->posix_acl || (body->valid & OBD_MD_FLACL));
1230 if (body->valid & OBD_MD_FLACL) {
1231 spin_lock(&lli->lli_lock);
1232 if (lli->lli_posix_acl)
1233 posix_acl_release(lli->lli_posix_acl);
1234 lli->lli_posix_acl = md->posix_acl;
1235 spin_unlock(&lli->lli_lock);
1239 if (body->valid & OBD_MD_FLID)
1240 inode->i_ino = body->ino;
1241 if (body->valid & OBD_MD_FLATIME)
1242 LTIME_S(inode->i_atime) = body->atime;
1243 if (body->valid & OBD_MD_FLMTIME &&
1244 body->mtime > LTIME_S(inode->i_mtime)) {
1245 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to "LPU64"\n",
1246 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
1247 LTIME_S(inode->i_mtime) = body->mtime;
1249 if (body->valid & OBD_MD_FLCTIME &&
1250 body->ctime > LTIME_S(inode->i_ctime))
1251 LTIME_S(inode->i_ctime) = body->ctime;
1252 if (body->valid & OBD_MD_FLMODE)
1253 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
1254 if (body->valid & OBD_MD_FLTYPE)
1255 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
1256 if (body->valid & OBD_MD_FLUID)
1257 inode->i_uid = body->uid;
1258 if (body->valid & OBD_MD_FLGID)
1259 inode->i_gid = body->gid;
1260 if (body->valid & OBD_MD_FLFLAGS)
1261 inode->i_flags = body->flags;
1262 if (body->valid & OBD_MD_FLNLINK)
1263 inode->i_nlink = body->nlink;
1264 if (body->valid & OBD_MD_FLGENER)
1265 inode->i_generation = body->generation;
1266 if (body->valid & OBD_MD_FLRDEV)
1267 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1268 inode->i_rdev = body->rdev;
1270 inode->i_rdev = old_decode_dev(body->rdev);
1272 if (body->valid & OBD_MD_FLSIZE)
1273 inode->i_size = body->size;
1274 if (body->valid & OBD_MD_FLBLOCKS)
1275 inode->i_blocks = body->blocks;
1277 if (body->valid & OBD_MD_FLSIZE)
1278 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
1281 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
1282 static struct backing_dev_info ll_backing_dev_info = {
1283 .ra_pages = 0, /* No readahead */
1284 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
1285 .capabilities = 0, /* Does contribute to dirty memory */
1287 .memory_backed = 0, /* Does contribute to dirty memory */
1292 void ll_read_inode2(struct inode *inode, void *opaque)
1294 struct lustre_md *md = opaque;
1295 struct ll_inode_info *lli = ll_i2info(inode);
1298 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
1299 inode->i_generation, inode);
1303 LASSERT(!lli->lli_smd);
1305 /* Core attributes from the MDS first. This is a new inode, and
1306 * the VFS doesn't zero times in the core inode so we have to do
1307 * it ourselves. They will be overwritten by either MDS or OST
1308 * attributes - we just need to make sure they aren't newer. */
1309 LTIME_S(inode->i_mtime) = 0;
1310 LTIME_S(inode->i_atime) = 0;
1311 LTIME_S(inode->i_ctime) = 0;
1313 ll_update_inode(inode, md);
1315 /* OIDEBUG(inode); */
1317 if (S_ISREG(inode->i_mode)) {
1318 struct ll_sb_info *sbi = ll_i2sbi(inode);
1319 inode->i_op = &ll_file_inode_operations;
1320 inode->i_fop = sbi->ll_fop;
1321 inode->i_mapping->a_ops = &ll_aops;
1323 } else if (S_ISDIR(inode->i_mode)) {
1324 inode->i_op = &ll_dir_inode_operations;
1325 inode->i_fop = &ll_dir_operations;
1326 inode->i_mapping->a_ops = &ll_dir_aops;
1328 } else if (S_ISLNK(inode->i_mode)) {
1329 inode->i_op = &ll_fast_symlink_inode_operations;
1332 inode->i_op = &ll_special_inode_operations;
1334 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1335 init_special_inode(inode, inode->i_mode,
1336 kdev_t_to_nr(inode->i_rdev));
1338 /* initializing backing dev info. */
1339 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
1341 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1343 lli->ll_save_ifop = inode->i_fop;
1345 if (S_ISCHR(inode->i_mode))
1346 inode->i_fop = &ll_special_chr_inode_fops;
1347 else if (S_ISBLK(inode->i_mode))
1348 inode->i_fop = &ll_special_blk_inode_fops;
1349 else if (S_ISFIFO(inode->i_mode))
1350 inode->i_fop = &ll_special_fifo_inode_fops;
1351 else if (S_ISSOCK(inode->i_mode))
1352 inode->i_fop = &ll_special_sock_inode_fops;
1357 int ll_iocontrol(struct inode *inode, struct file *file,
1358 unsigned int cmd, unsigned long arg)
1360 struct ll_sb_info *sbi = ll_i2sbi(inode);
1361 struct ptlrpc_request *req = NULL;
1366 case EXT3_IOC_GETFLAGS: {
1368 struct mds_body *body;
1370 ll_inode2fid(&fid, inode);
1371 rc = mdc_getattr(sbi->ll_mdc_exp, &fid, OBD_MD_FLFLAGS,0,&req);
1373 CERROR("failure %d inode %lu\n", rc, inode->i_ino);
1377 body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
1379 if (body->flags & S_APPEND)
1380 flags |= EXT3_APPEND_FL;
1381 if (body->flags & S_IMMUTABLE)
1382 flags |= EXT3_IMMUTABLE_FL;
1383 if (body->flags & S_NOATIME)
1384 flags |= EXT3_NOATIME_FL;
1386 ptlrpc_req_finished (req);
1388 RETURN(put_user(flags, (int *)arg));
1390 case EXT3_IOC_SETFLAGS: {
1391 struct mdc_op_data op_data;
1394 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
1396 if (get_user(flags, (int *)arg))
1403 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
1405 memset(&attr, 0x0, sizeof(attr));
1406 attr.ia_attr_flags = flags;
1407 attr.ia_valid |= ATTR_ATTR_FLAG;
1409 rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
1410 &attr, NULL, 0, NULL, 0, &req);
1412 ptlrpc_req_finished(req);
1413 if (rc != -EPERM && rc != -EACCES)
1414 CERROR("mdc_setattr fails: rc = %d\n", rc);
1418 ptlrpc_req_finished(req);
1420 oa->o_id = lsm->lsm_object_id;
1421 oa->o_flags = flags;
1422 oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS;
1424 obdo_from_inode(oa, inode, OBD_MD_FLFID | OBD_MD_FLGENER);
1425 rc = obd_setattr(sbi->ll_osc_exp, oa, lsm, NULL);
1428 if (rc != -EPERM && rc != -EACCES)
1429 CERROR("mdc_setattr fails: rc = %d\n", rc);
1433 if (flags & EXT3_APPEND_FL)
1434 inode->i_flags |= S_APPEND;
1436 inode->i_flags &= ~S_APPEND;
1437 if (flags & EXT3_IMMUTABLE_FL)
1438 inode->i_flags |= S_IMMUTABLE;
1440 inode->i_flags &= ~S_IMMUTABLE;
1441 if (flags & EXT3_NOATIME_FL)
1442 inode->i_flags |= S_NOATIME;
1444 inode->i_flags &= ~S_NOATIME;
1455 void ll_umount_begin(struct super_block *sb)
1457 struct lustre_sb_info *lsi = s2lsi(sb);
1458 struct ll_sb_info *sbi = ll_s2sbi(sb);
1459 struct obd_device *obd;
1460 struct obd_ioctl_data ioc_data = { 0 };
1463 /* Make the MGC not try to cancel locks */
1464 lsi->lsi_flags |= LSI_UMOUNT_FAILOVER;
1466 CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb,
1467 sb->s_count, atomic_read(&sb->s_active));
1469 obd = class_exp2obd(sbi->ll_mdc_exp);
1471 CERROR("Invalid MDC connection handle "LPX64"\n",
1472 sbi->ll_mdc_exp->exp_handle.h_cookie);
1476 obd->obd_no_recov = 1;
1477 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data,
1480 obd = class_exp2obd(sbi->ll_osc_exp);
1482 CERROR("Invalid LOV connection handle "LPX64"\n",
1483 sbi->ll_osc_exp->exp_handle.h_cookie);
1487 obd->obd_no_recov = 1;
1488 obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data,
1491 /* Really, we'd like to wait until there are no requests outstanding,
1492 * and then continue. For now, we just invalidate the requests,
1493 * schedule, and hope.
1500 int ll_remount_fs(struct super_block *sb, int *flags, char *data)
1502 struct ll_sb_info *sbi = ll_s2sbi(sb);
1506 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
1507 read_only = *flags & MS_RDONLY;
1508 err = obd_set_info(sbi->ll_mdc_exp, strlen("read-only"),
1509 "read-only", sizeof(read_only), &read_only);
1511 CERROR("Failed to change the read-only flag during "
1512 "remount: %d\n", err);
1517 sb->s_flags |= MS_RDONLY;
1519 sb->s_flags &= ~MS_RDONLY;
1524 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
1525 struct ptlrpc_request *req, int offset,struct super_block *sb)
1527 struct lustre_md md;
1528 struct ll_sb_info *sbi = NULL;
1532 LASSERT(*inode || sb);
1533 sbi = sb ? ll_s2sbi(sb) : ll_i2sbi(*inode);
1534 prune_deathrow(sbi, 1);
1536 rc = mdc_req2lustre_md(req, offset, exp, &md);
1541 ll_update_inode(*inode, &md);
1544 *inode = ll_iget(sb, md.body->ino, &md);
1545 if (*inode == NULL || is_bad_inode(*inode)) {
1546 mdc_free_lustre_md(exp, &md);
1548 CERROR("new_inode -fatal: rc %d\n", rc);
1553 rc = obd_checkmd(exp, ll_i2mdcexp(*inode),
1554 ll_i2info(*inode)->lli_smd);
1559 char *llap_origins[] = {
1560 [LLAP_ORIGIN_UNKNOWN] = "--",
1561 [LLAP_ORIGIN_READPAGE] = "rp",
1562 [LLAP_ORIGIN_READAHEAD] = "ra",
1563 [LLAP_ORIGIN_COMMIT_WRITE] = "cw",
1564 [LLAP_ORIGIN_WRITEPAGE] = "wp",
1567 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
1568 struct list_head *list)
1570 struct ll_async_page *llap;
1571 struct list_head *pos;
1573 list_for_each(pos, list) {
1574 if (pos == &sbi->ll_pglist)
1576 llap = list_entry(pos, struct ll_async_page, llap_pglist_item);
1577 if (llap->llap_page == NULL)
1585 EXPORT_SYMBOL(ll_fill_super);
1586 EXPORT_SYMBOL(ll_put_super);
1587 EXPORT_SYMBOL(ll_remount_fs);
1588 EXPORT_SYMBOL(ll_umount_begin);