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/random.h>
28 #include <linux/version.h>
29 #include <linux/lustre_lite.h>
30 #include <linux/lustre_ha.h>
31 #include <linux/lustre_dlm.h>
32 #include <linux/init.h>
34 #include <linux/lprocfs_status.h>
35 #include "llite_internal.h"
37 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
38 kmem_cache_t *ll_file_data_slab;
39 extern struct address_space_operations ll_aops;
40 extern struct address_space_operations ll_dir_aops;
41 struct super_operations ll_super_operations;
43 /* /proc/lustre/llite root that tracks llite mount points */
44 struct proc_dir_entry *proc_lustre_fs_root = NULL;
46 extern void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
47 extern int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
48 struct super_block *sb,
49 char *osc, char *mdc);
51 extern int ll_recover(struct recovd_data *, int);
52 extern int ll_commitcbd_setup(struct ll_sb_info *);
53 extern int ll_commitcbd_cleanup(struct ll_sb_info *);
55 static char *ll_read_opt(const char *opt, char *data)
61 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
62 if (strncmp(opt, data, strlen(opt)))
64 if ((value = strchr(data, '=')) == NULL)
68 OBD_ALLOC(retval, strlen(value) + 1);
70 CERROR("out of memory!\n");
74 memcpy(retval, value, strlen(value)+1);
75 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
79 static int ll_set_opt(const char *opt, char *data, int fl)
83 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
84 if (strncmp(opt, data, strlen(opt)))
90 static void ll_options(char *options, char **ost, char **mds, int *flags)
100 for (this_char = strtok (options, ",");
102 this_char = strtok (NULL, ",")) {
103 CDEBUG(D_SUPER, "this_char %s\n", this_char);
104 if ((!*ost && (*ost = ll_read_opt("osc", this_char)))||
105 (!*mds && (*mds = ll_read_opt("mdc", this_char)))||
106 (!(*flags & LL_SBI_NOLCK) &&
107 ((*flags) = (*flags) |
108 ll_set_opt("nolock", this_char, LL_SBI_NOLCK))))
115 #define log2(n) ffz(~(n))
118 static struct super_block *ll_read_super(struct super_block *sb,
119 void *data, int silent)
121 struct inode *root = 0;
122 struct obd_device *obd;
123 struct ll_sb_info *sbi;
127 struct ll_fid rootfid;
128 struct obd_statfs osfs;
129 struct ptlrpc_request *request = NULL;
130 struct ptlrpc_connection *mdc_conn;
131 struct ll_read_inode2_cookie lic;
133 struct obd_uuid param_uuid;
137 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
138 OBD_ALLOC(sbi, sizeof(*sbi));
142 INIT_LIST_HEAD(&sbi->ll_conn_chain);
143 INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list);
144 generate_random_uuid(uuid);
145 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
147 sb->u.generic_sbp = sbi;
149 ll_options(data, &osc, &mdc, &sbi->ll_flags);
153 GOTO(out_free, sb = NULL);
158 GOTO(out_free, sb = NULL);
161 strncpy(param_uuid.uuid, mdc, sizeof(param_uuid.uuid));
162 obd = class_uuid2obd(¶m_uuid);
164 CERROR("MDC %s: not setup or attached\n", mdc);
165 GOTO(out_free, sb = NULL);
168 err = obd_connect(&sbi->ll_mdc_conn, obd, &sbi->ll_sb_uuid);
170 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
171 GOTO(out_free, sb = NULL);
174 mdc_conn = sbi2mdc(sbi)->cl_import->imp_connection;
176 strncpy(param_uuid.uuid, osc, sizeof(param_uuid.uuid));
177 obd = class_uuid2obd(¶m_uuid);
179 CERROR("OSC %s: not setup or attached\n", osc);
180 GOTO(out_mdc, sb = NULL);
183 err = obd_connect(&sbi->ll_osc_conn, obd, &sbi->ll_sb_uuid);
185 CERROR("cannot connect to %s: rc = %d\n", osc, err);
186 GOTO(out_mdc, sb = NULL);
189 err = mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
191 CERROR("cannot mds_connect: rc = %d\n", err);
192 GOTO(out_osc, sb = NULL);
194 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
195 sbi->ll_rootino = rootfid.id;
197 memset(&osfs, 0, sizeof(osfs));
198 err = obd_statfs(&sbi->ll_mdc_conn, &osfs);
199 sb->s_blocksize = osfs.os_bsize;
200 sb->s_blocksize_bits = log2(osfs.os_bsize);
201 sb->s_magic = LL_SUPER_MAGIC;
202 sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
204 sb->s_op = &ll_super_operations;
207 * XXX: move this to after cbd setup? */
208 err = mdc_getattr(&sbi->ll_mdc_conn, &rootfid,
209 OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
211 CERROR("mdc_getattr failed for root: rc = %d\n", err);
212 GOTO(out_osc, sb = NULL);
215 /* initialize committed transaction callback daemon */
216 spin_lock_init(&sbi->ll_commitcbd_lock);
217 init_waitqueue_head(&sbi->ll_commitcbd_waitq);
218 init_waitqueue_head(&sbi->ll_commitcbd_ctl_waitq);
219 sbi->ll_commitcbd_flags = 0;
220 err = ll_commitcbd_setup(sbi);
222 CERROR("failed to start commit callback daemon: rc = %d\n",err);
223 ptlrpc_req_finished (request);
224 GOTO(out_osc, sb = NULL);
227 lic.lic_body = lustre_msg_buf(request->rq_repmsg, 0,
228 sizeof(*lic.lic_body));
229 LASSERT (lic.lic_body != NULL); /* checked by mdc_getattr() */
230 LASSERT_REPSWABBED (request, 0); /* swabbed by mdc_getattr() */
234 LASSERT(sbi->ll_rootino != 0);
235 root = iget4(sb, sbi->ll_rootino, NULL, &lic);
237 ptlrpc_req_finished(request);
239 if (root == NULL || is_bad_inode(root)) {
240 /* XXX might need iput() for bad inode */
241 CERROR("lustre_lite: bad iget4 for root\n");
242 GOTO(out_cbd, sb = NULL);
245 sb->s_root = d_alloc_root(root);
247 if (proc_lustre_fs_root) {
248 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
251 CERROR("could not register mount in /proc/lustre");
256 OBD_FREE(mdc, strlen(mdc) + 1);
258 OBD_FREE(osc, strlen(osc) + 1);
263 ll_commitcbd_cleanup(sbi);
265 obd_disconnect(&sbi->ll_osc_conn, 0);
267 obd_disconnect(&sbi->ll_mdc_conn, 0);
269 lprocfs_unregister_mountpoint(sbi);
270 OBD_FREE(sbi, sizeof(*sbi));
273 } /* ll_read_super */
275 static void ll_put_super(struct super_block *sb)
277 struct ll_sb_info *sbi = ll_s2sbi(sb);
278 struct list_head *tmp, *next;
279 struct ll_fid rootfid;
280 struct obd_device *obd = class_conn2obd(&sbi->ll_mdc_conn);
283 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
284 list_del(&sbi->ll_conn_chain);
285 ll_commitcbd_cleanup(sbi);
286 obd_disconnect(&sbi->ll_osc_conn, 0);
288 /* NULL request to force sync on the MDS, and get the last_committed
289 * value to flush remaining RPCs from the sending queue on client.
291 * XXX This should be an mdc_sync() call to sync the whole MDS fs,
292 * which we can call for other reasons as well.
294 if (!obd->obd_no_recov)
295 mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
297 lprocfs_unregister_mountpoint(sbi);
298 if (sbi->ll_proc_root) {
299 lprocfs_remove(sbi->ll_proc_root);
300 sbi->ll_proc_root = NULL;
303 obd_disconnect(&sbi->ll_mdc_conn, 0);
305 spin_lock(&dcache_lock);
306 list_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
307 struct dentry *dentry = list_entry(tmp, struct dentry, d_hash);
308 shrink_dcache_parent(dentry);
310 spin_unlock(&dcache_lock);
312 OBD_FREE(sbi, sizeof(*sbi));
317 static void ll_clear_inode(struct inode *inode)
319 struct ll_sb_info *sbi = ll_i2sbi(inode);
320 struct ll_inode_info *lli = ll_i2info(inode);
324 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
325 inode->i_generation, inode);
326 rc = ll_mdc_cancel_unused(&sbi->ll_mdc_conn, inode,
327 LDLM_FL_NO_CALLBACK, inode);
329 CERROR("ll_mdc_cancel_unused: %d\n", rc);
330 /* XXX FIXME do something dramatic */
333 if (atomic_read(&inode->i_count) != 0)
334 CERROR("clearing in-use inode %lu: count = %d\n",
335 inode->i_ino, atomic_read(&inode->i_count));
338 rc = obd_cancel_unused(&sbi->ll_osc_conn, lli->lli_smd,
339 LDLM_FL_WARN, inode);
341 CERROR("obd_cancel_unused: %d\n", rc);
342 /* XXX FIXME do something dramatic */
344 obd_free_memmd(&sbi->ll_osc_conn, &lli->lli_smd);
348 if (lli->lli_symlink_name) {
349 OBD_FREE(lli->lli_symlink_name,
350 strlen(lli->lli_symlink_name) + 1);
351 lli->lli_symlink_name = NULL;
358 static void ll_delete_inode(struct inode *inode)
361 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
362 inode->i_generation, inode);
363 if (S_ISREG(inode->i_mode)) {
366 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
368 /* mcreate with no open */
372 if (lsm->lsm_object_id == 0) {
373 CERROR("This really happens\n");
374 /* No obdo was ever created */
382 oa->o_id = lsm->lsm_object_id;
383 obdo_from_inode(oa, inode, OBD_MD_FLID | OBD_MD_FLTYPE);
385 err = obd_destroy(ll_i2obdconn(inode), oa, lsm, NULL);
389 "inode %lu obd_destroy objid "LPX64" error %d\n",
390 inode->i_ino, lsm->lsm_object_id, err);
398 /* like inode_setattr, but doesn't mark the inode dirty */
399 static int ll_attr2inode(struct inode *inode, struct iattr *attr, int trunc)
401 unsigned int ia_valid = attr->ia_valid;
404 if ((ia_valid & ATTR_SIZE) && trunc) {
405 if (attr->ia_size > ll_file_maxbytes(inode)) {
409 error = vmtruncate(inode, attr->ia_size);
412 } else if (ia_valid & ATTR_SIZE)
413 inode->i_size = attr->ia_size;
415 if (ia_valid & ATTR_UID)
416 inode->i_uid = attr->ia_uid;
417 if (ia_valid & ATTR_GID)
418 inode->i_gid = attr->ia_gid;
419 if (ia_valid & ATTR_ATIME)
420 inode->i_atime = attr->ia_atime;
421 if (ia_valid & ATTR_MTIME)
422 inode->i_mtime = attr->ia_mtime;
423 if (ia_valid & ATTR_CTIME)
424 inode->i_ctime = attr->ia_ctime;
425 if (ia_valid & ATTR_MODE) {
426 inode->i_mode = attr->ia_mode;
427 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
428 inode->i_mode &= ~S_ISGID;
434 int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc)
436 struct ptlrpc_request *request = NULL;
437 struct ll_sb_info *sbi = ll_i2sbi(inode);
441 /* change incore inode */
442 err = ll_attr2inode(inode, attr, do_trunc);
446 /* Don't send size changes to MDS to avoid "fast EA" problems, and
447 * also avoid a pointless RPC (we get file size from OST anyways).
449 attr->ia_valid &= ~ATTR_SIZE;
450 if (attr->ia_valid) {
451 struct mdc_op_data op_data;
453 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
454 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
455 attr, NULL, 0, &request);
457 CERROR("mdc_setattr fails: err = %d\n", err);
459 ptlrpc_req_finished(request);
460 if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_MTIME_SET) {
461 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
465 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
466 inode->i_ino, attr->ia_mtime);
467 oa.o_id = lsm->lsm_object_id;
469 oa.o_valid = OBD_MD_FLID |OBD_MD_FLTYPE |OBD_MD_FLMTIME;
470 oa.o_mtime = attr->ia_mtime;
471 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
473 CERROR("obd_setattr fails: rc=%d\n", err);
483 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
485 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
486 struct ll_sb_info *sbi = ll_i2sbi(inode);
487 struct ptlrpc_request *request = NULL;
488 struct mdc_op_data op_data;
491 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
492 inode->i_generation, inode);
494 if ((attr->ia_valid & ATTR_SIZE)) {
495 struct ldlm_extent extent = {attr->ia_size, OBD_OBJECT_EOF};
496 struct lustre_handle lockh = { 0 };
498 if (attr->ia_size > ll_file_maxbytes(inode))
501 /* writeback uses inode->i_size to determine how far out
502 * its cached pages go. ll_truncate gets a PW lock, canceling
503 * our lock, _after_ it has updated i_size. this can confuse
505 * If this file doesn't have stripes yet, it is already,
506 * by definition, truncated. */
507 if ((attr->ia_valid & ATTR_FROM_OPEN) && lsm == NULL) {
508 LASSERT(attr->ia_size == 0);
509 GOTO(skip_extent_lock, rc = 0);
512 /* we really need to get our PW lock before we change
513 * inode->i_size. if we don't we can race with other
514 * i_size updaters on our node, like ll_file_read. we
515 * can also race with i_size propogation to other
516 * nodes through dirtying and writeback of final cached
517 * pages. this last one is especially bad for racing
518 * o_append users on other nodes. */
519 rc = ll_extent_lock_no_validate(NULL, inode, lsm, LCK_PW,
521 if (rc != ELDLM_OK) {
527 rc = vmtruncate(inode, attr->ia_size);
529 set_bit(LLI_F_HAVE_SIZE_LOCK,
530 &ll_i2info(inode)->lli_flags);
532 /* unlock now as we don't mind others file lockers racing with
533 * the mds updates below? */
534 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
536 CERROR("ll_extent_unlock failed: %d\n", err);
542 /* Don't send size changes to MDS to avoid "fast EA" problems, and
543 * also avoid a pointless RPC (we get file size from OST anyways).
545 attr->ia_valid &= ~ATTR_SIZE;
549 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
551 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
552 attr, NULL, 0, &request);
554 CERROR("mdc_setattr fails: err = %d\n", err);
556 ptlrpc_req_finished(request);
558 if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_MTIME_SET)) {
559 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
564 CDEBUG(D_INODE, "no lsm: not setting mtime on OSTs\n");
568 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
569 inode->i_ino, attr->ia_mtime);
570 oa.o_id = lsm->lsm_object_id;
572 oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMTIME;
573 oa.o_mtime = attr->ia_mtime;
574 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
576 CERROR("obd_setattr fails: rc=%d\n", err);
584 int ll_setattr(struct dentry *de, struct iattr *attr)
586 int rc = inode_change_ok(de->d_inode, attr);
587 CDEBUG(D_VFSTRACE, "VFS Op:name=%s\n", de->d_name.name);
590 lprocfs_counter_incr(ll_i2sbi(de->d_inode)->ll_stats, LPROC_LL_SETATTR);
592 return ll_inode_setattr(de->d_inode, attr, 1);
595 static int ll_statfs(struct super_block *sb, struct statfs *sfs)
597 struct ll_sb_info *sbi = ll_s2sbi(sb);
598 struct obd_statfs osfs;
602 CDEBUG(D_VFSTRACE, "VFS Op:\n");
603 lprocfs_counter_incr(sbi->ll_stats, LPROC_LL_STAFS);
604 memset(sfs, 0, sizeof(*sfs));
605 rc = obd_statfs(&sbi->ll_mdc_conn, &osfs);
606 statfs_unpack(sfs, &osfs);
608 CERROR("mdc_statfs fails: rc = %d\n", rc);
610 CDEBUG(D_SUPER, "mdc_statfs shows blocks "LPU64"/"LPU64
611 " objects "LPU64"/"LPU64"\n",
612 osfs.os_bavail, osfs.os_blocks,
613 osfs.os_ffree, osfs.os_files);
615 /* temporary until mds_statfs returns statfs info for all OSTs */
617 rc = obd_statfs(&sbi->ll_osc_conn, &osfs);
619 CERROR("obd_statfs fails: rc = %d\n", rc);
622 CDEBUG(D_SUPER, "obd_statfs shows blocks "LPU64"/"LPU64
623 " objects "LPU64"/"LPU64"\n",
624 osfs.os_bavail, osfs.os_blocks,
625 osfs.os_ffree, osfs.os_files);
627 while (osfs.os_blocks > ~0UL) {
630 osfs.os_blocks >>= 1;
632 osfs.os_bavail >>= 1;
635 sfs->f_blocks = osfs.os_blocks;
636 sfs->f_bfree = osfs.os_bfree;
637 sfs->f_bavail = osfs.os_bavail;
639 /* If we don't have as many objects free on the OST as inodes
640 * on the MDS, we reduce the total number of inodes to
641 * compensate, so that the "inodes in use" number is correct.
643 if (osfs.os_ffree < (__u64)sfs->f_ffree) {
644 sfs->f_files = (sfs->f_files - sfs->f_ffree) +
646 sfs->f_ffree = osfs.os_ffree;
654 void dump_lsm(int level, struct lov_stripe_md *lsm)
656 CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic %#08x, "
657 "stripe_size %#08x, offset %u, stripe_count %u\n",
658 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
659 lsm->lsm_stripe_size, lsm->lsm_stripe_offset,
660 lsm->lsm_stripe_count);
663 void ll_update_inode(struct inode *inode, struct mds_body *body,
664 struct lov_stripe_md *lsm)
666 struct ll_inode_info *lli = ll_i2info(inode);
668 LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
670 if (lli->lli_smd == NULL) {
671 lli->lli_maxbytes = lsm->lsm_maxbytes;
672 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
673 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
676 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
677 CERROR("lsm mismatch for inode %ld\n",
679 CERROR("lli_smd:\n");
680 dump_lsm(D_ERROR, lli->lli_smd);
682 dump_lsm(D_ERROR, lsm);
688 if (body->valid & OBD_MD_FLID)
689 inode->i_ino = body->ino;
690 if (body->valid & OBD_MD_FLATIME)
691 LTIME_S(inode->i_atime) = body->atime;
692 if (body->valid & OBD_MD_FLMTIME)
693 LTIME_S(inode->i_mtime) = body->mtime;
694 if (body->valid & OBD_MD_FLCTIME)
695 LTIME_S(inode->i_ctime) = body->ctime;
696 if (body->valid & OBD_MD_FLMODE)
697 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
698 if (body->valid & OBD_MD_FLTYPE)
699 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
700 if (body->valid & OBD_MD_FLUID)
701 inode->i_uid = body->uid;
702 if (body->valid & OBD_MD_FLGID)
703 inode->i_gid = body->gid;
704 if (body->valid & OBD_MD_FLFLAGS)
705 inode->i_flags = body->flags;
706 if (body->valid & OBD_MD_FLNLINK)
707 inode->i_nlink = body->nlink;
708 if (body->valid & OBD_MD_FLGENER)
709 inode->i_generation = body->generation;
710 if (body->valid & OBD_MD_FLRDEV)
711 inode->i_rdev = body->rdev;
712 if (body->valid & OBD_MD_FLSIZE)
713 inode->i_size = body->size;
714 if (body->valid & OBD_MD_FLBLOCKS)
715 inode->i_blocks = body->blocks;
718 static void ll_read_inode2(struct inode *inode, void *opaque)
720 struct ll_read_inode2_cookie *lic = opaque;
721 struct mds_body *body = lic->lic_body;
722 struct ll_inode_info *lli = ll_i2info(inode);
724 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
725 inode->i_generation, inode);
727 sema_init(&lli->lli_open_sem, 1);
728 spin_lock_init(&lli->lli_read_extent_lock);
729 INIT_LIST_HEAD(&lli->lli_read_extents);
730 ll_lldo_init(&lli->lli_dirty);
732 /* We default to 2T-4k until the LSM is created/read, at which point
733 * it'll be updated. */
734 lli->lli_maxbytes = LUSTRE_STRIPE_MAXBYTES;
736 LASSERT(!lli->lli_smd);
738 /* core attributes from the MDS first */
739 ll_update_inode(inode, body, lic->lic_lsm);
741 /* OIDEBUG(inode); */
743 if (S_ISREG(inode->i_mode)) {
744 inode->i_op = &ll_file_inode_operations;
745 inode->i_fop = &ll_file_operations;
746 inode->i_mapping->a_ops = &ll_aops;
748 } else if (S_ISDIR(inode->i_mode)) {
749 inode->i_op = &ll_dir_inode_operations;
750 inode->i_fop = &ll_dir_operations;
751 inode->i_mapping->a_ops = &ll_dir_aops;
753 } else if (S_ISLNK(inode->i_mode)) {
754 inode->i_op = &ll_fast_symlink_inode_operations;
757 inode->i_op = &ll_special_inode_operations;
758 init_special_inode(inode, inode->i_mode, inode->i_rdev);
763 void ll_umount_begin(struct super_block *sb)
765 struct ll_sb_info *sbi = ll_s2sbi(sb);
766 struct obd_device *obd;
767 struct obd_ioctl_data ioc_data = { 0 };
770 CDEBUG(D_VFSTRACE, "VFS Op:\n");
772 obd = class_conn2obd(&sbi->ll_mdc_conn);
773 obd->obd_no_recov = 1;
774 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_mdc_conn, sizeof ioc_data,
777 obd = class_conn2obd(&sbi->ll_osc_conn);
778 obd->obd_no_recov = 1;
779 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_osc_conn, sizeof ioc_data,
782 /* Really, we'd like to wait until there are no requests outstanding,
783 * and then continue. For now, we just invalidate the requests,
784 * schedule, and hope.
791 /* exported operations */
792 struct super_operations ll_super_operations =
794 read_inode2: ll_read_inode2,
795 clear_inode: ll_clear_inode,
796 // delete_inode: ll_delete_inode,
797 put_super: ll_put_super,
799 umount_begin: ll_umount_begin
802 static struct file_system_type lustre_lite_fs_type = {
805 read_super: ll_read_super,
809 static int __init init_lustre_lite(void)
811 printk(KERN_INFO "Lustre Lite Client File System; "
812 "info@clusterfs.com\n");
813 ll_file_data_slab = kmem_cache_create("ll_file_data",
814 sizeof(struct ll_file_data), 0,
815 SLAB_HWCACHE_ALIGN, NULL, NULL);
816 if (ll_file_data_slab == NULL)
819 proc_lustre_fs_root = proc_lustre_root ? proc_mkdir("llite", proc_lustre_root) : NULL;
821 return register_filesystem(&lustre_lite_fs_type);
824 static void __exit exit_lustre_lite(void)
826 unregister_filesystem(&lustre_lite_fs_type);
827 kmem_cache_destroy(ll_file_data_slab);
829 if (proc_lustre_fs_root) {
830 lprocfs_remove(proc_lustre_fs_root);
831 proc_lustre_fs_root = NULL;
835 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
836 MODULE_DESCRIPTION("Lustre Lite Client File System");
837 MODULE_LICENSE("GPL");
839 module_init(init_lustre_lite);
840 module_exit(exit_lustre_lite);