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 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
47 struct super_block *sb,
48 char *osc, char *mdc);
50 extern int ll_recover(struct recovd_data *, int);
51 extern int ll_commitcbd_setup(struct ll_sb_info *);
52 extern int ll_commitcbd_cleanup(struct ll_sb_info *);
54 static char *ll_read_opt(const char *opt, char *data)
60 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
61 if (strncmp(opt, data, strlen(opt)))
63 if ((value = strchr(data, '=')) == NULL)
67 OBD_ALLOC(retval, strlen(value) + 1);
69 CERROR("out of memory!\n");
73 memcpy(retval, value, strlen(value)+1);
74 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
78 static int ll_set_opt(const char *opt, char *data, int fl)
82 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
83 if (strncmp(opt, data, strlen(opt)))
89 static void ll_options(char *options, char **ost, char **mds, int *flags)
99 for (this_char = strtok (options, ",");
101 this_char = strtok (NULL, ",")) {
102 CDEBUG(D_SUPER, "this_char %s\n", this_char);
103 if ((!*ost && (*ost = ll_read_opt("osc", this_char)))||
104 (!*mds && (*mds = ll_read_opt("mdc", this_char)))||
105 (!(*flags & LL_SBI_NOLCK) &&
106 ((*flags) = (*flags) |
107 ll_set_opt("nolock", this_char, LL_SBI_NOLCK))))
114 #define log2(n) ffz(~(n))
117 static struct super_block *ll_read_super(struct super_block *sb,
118 void *data, int silent)
120 struct inode *root = 0;
121 struct obd_device *obd;
122 struct ll_sb_info *sbi;
126 struct ll_fid rootfid;
127 struct obd_statfs osfs;
128 struct ptlrpc_request *request = NULL;
129 struct ptlrpc_connection *mdc_conn;
130 struct ll_read_inode2_cookie lic;
132 struct obd_uuid param_uuid;
136 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
137 OBD_ALLOC(sbi, sizeof(*sbi));
141 INIT_LIST_HEAD(&sbi->ll_conn_chain);
142 INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list);
143 generate_random_uuid(uuid);
144 spin_lock_init(&sbi->ll_iostats.fis_lock);
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 OBD_FREE(sbi, sizeof(*sbi));
272 } /* ll_read_super */
274 static void ll_put_super(struct super_block *sb)
276 struct ll_sb_info *sbi = ll_s2sbi(sb);
277 struct list_head *tmp, *next;
278 struct ll_fid rootfid;
279 struct obd_device *obd = class_conn2obd(&sbi->ll_mdc_conn);
282 CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
283 list_del(&sbi->ll_conn_chain);
284 ll_commitcbd_cleanup(sbi);
285 obd_disconnect(&sbi->ll_osc_conn, 0);
287 /* NULL request to force sync on the MDS, and get the last_committed
288 * value to flush remaining RPCs from the sending queue on client.
290 * XXX This should be an mdc_sync() call to sync the whole MDS fs,
291 * which we can call for other reasons as well.
293 if (!obd->obd_no_recov)
294 mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
296 if (sbi->ll_proc_root) {
297 lprocfs_remove(sbi->ll_proc_root);
298 sbi->ll_proc_root = NULL;
301 obd_disconnect(&sbi->ll_mdc_conn, 0);
303 spin_lock(&dcache_lock);
304 list_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list) {
305 struct dentry *dentry = list_entry(tmp, struct dentry, d_hash);
306 shrink_dcache_parent(dentry);
308 spin_unlock(&dcache_lock);
310 OBD_FREE(sbi, sizeof(*sbi));
315 static void ll_clear_inode(struct inode *inode)
317 struct ll_sb_info *sbi = ll_i2sbi(inode);
318 struct ll_inode_info *lli = ll_i2info(inode);
322 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
323 inode->i_generation, inode);
324 rc = ll_mdc_cancel_unused(&sbi->ll_mdc_conn, inode,
325 LDLM_FL_NO_CALLBACK, inode);
327 CERROR("ll_mdc_cancel_unused: %d\n", rc);
328 /* XXX FIXME do something dramatic */
331 if (atomic_read(&inode->i_count) != 0)
332 CERROR("clearing in-use inode %lu: count = %d\n",
333 inode->i_ino, atomic_read(&inode->i_count));
336 rc = obd_cancel_unused(&sbi->ll_osc_conn, lli->lli_smd,
337 LDLM_FL_WARN, inode);
339 CERROR("obd_cancel_unused: %d\n", rc);
340 /* XXX FIXME do something dramatic */
342 obd_free_memmd(&sbi->ll_osc_conn, &lli->lli_smd);
346 if (lli->lli_symlink_name) {
347 OBD_FREE(lli->lli_symlink_name,
348 strlen(lli->lli_symlink_name) + 1);
349 lli->lli_symlink_name = NULL;
356 static void ll_delete_inode(struct inode *inode)
359 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
360 inode->i_generation, inode);
361 if (S_ISREG(inode->i_mode)) {
364 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
366 /* mcreate with no open */
370 if (lsm->lsm_object_id == 0) {
371 CERROR("This really happens\n");
372 /* No obdo was ever created */
380 oa->o_id = lsm->lsm_object_id;
381 obdo_from_inode(oa, inode, OBD_MD_FLID | OBD_MD_FLTYPE);
383 err = obd_destroy(ll_i2obdconn(inode), oa, lsm, NULL);
387 "inode %lu obd_destroy objid "LPX64" error %d\n",
388 inode->i_ino, lsm->lsm_object_id, err);
396 /* like inode_setattr, but doesn't mark the inode dirty */
397 static int ll_attr2inode(struct inode *inode, struct iattr *attr, int trunc)
399 unsigned int ia_valid = attr->ia_valid;
402 if ((ia_valid & ATTR_SIZE) && trunc) {
403 if (attr->ia_size > ll_file_maxbytes(inode)) {
407 error = vmtruncate(inode, attr->ia_size);
410 } else if (ia_valid & ATTR_SIZE)
411 inode->i_size = attr->ia_size;
413 if (ia_valid & ATTR_UID)
414 inode->i_uid = attr->ia_uid;
415 if (ia_valid & ATTR_GID)
416 inode->i_gid = attr->ia_gid;
417 if (ia_valid & ATTR_ATIME)
418 inode->i_atime = attr->ia_atime;
419 if (ia_valid & ATTR_MTIME)
420 inode->i_mtime = attr->ia_mtime;
421 if (ia_valid & ATTR_CTIME)
422 inode->i_ctime = attr->ia_ctime;
423 if (ia_valid & ATTR_MODE) {
424 inode->i_mode = attr->ia_mode;
425 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
426 inode->i_mode &= ~S_ISGID;
432 int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc)
434 struct ptlrpc_request *request = NULL;
435 struct ll_sb_info *sbi = ll_i2sbi(inode);
439 /* change incore inode */
440 err = ll_attr2inode(inode, attr, do_trunc);
444 /* Don't send size changes to MDS to avoid "fast EA" problems, and
445 * also avoid a pointless RPC (we get file size from OST anyways).
447 attr->ia_valid &= ~ATTR_SIZE;
448 if (attr->ia_valid) {
449 struct mdc_op_data op_data;
451 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
452 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
453 attr, NULL, 0, &request);
455 CERROR("mdc_setattr fails: err = %d\n", err);
457 ptlrpc_req_finished(request);
458 if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_MTIME_SET) {
459 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
463 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
464 inode->i_ino, attr->ia_mtime);
465 oa.o_id = lsm->lsm_object_id;
467 oa.o_valid = OBD_MD_FLID |OBD_MD_FLTYPE |OBD_MD_FLMTIME;
468 oa.o_mtime = attr->ia_mtime;
469 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
471 CERROR("obd_setattr fails: rc=%d\n", err);
481 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
483 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
484 struct ll_sb_info *sbi = ll_i2sbi(inode);
485 struct ptlrpc_request *request = NULL;
486 struct mdc_op_data op_data;
489 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
490 inode->i_generation, inode);
492 if ((attr->ia_valid & ATTR_SIZE)) {
493 struct ldlm_extent extent = {attr->ia_size, OBD_OBJECT_EOF};
494 struct lustre_handle lockh = { 0 };
496 if (attr->ia_size > ll_file_maxbytes(inode))
499 /* writeback uses inode->i_size to determine how far out
500 * its cached pages go. ll_truncate gets a PW lock, canceling
501 * our lock, _after_ it has updated i_size. this can confuse
503 * If this file doesn't have stripes yet, it is already,
504 * by definition, truncated. */
505 if ((attr->ia_valid & ATTR_FROM_OPEN) && lsm == NULL) {
506 LASSERT(attr->ia_size == 0);
507 GOTO(skip_extent_lock, rc = 0);
510 /* we really need to get our PW lock before we change
511 * inode->i_size. if we don't we can race with other
512 * i_size updaters on our node, like ll_file_read. we
513 * can also race with i_size propogation to other
514 * nodes through dirtying and writeback of final cached
515 * pages. this last one is especially bad for racing
516 * o_append users on other nodes. */
517 rc = ll_extent_lock_no_validate(NULL, inode, lsm, LCK_PW,
519 if (rc != ELDLM_OK) {
525 rc = vmtruncate(inode, attr->ia_size);
527 set_bit(LLI_F_HAVE_SIZE_LOCK,
528 &ll_i2info(inode)->lli_flags);
530 /* unlock now as we don't mind others file lockers racing with
531 * the mds updates below? */
532 err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
534 CERROR("ll_extent_unlock failed: %d\n", err);
540 /* Don't send size changes to MDS to avoid "fast EA" problems, and
541 * also avoid a pointless RPC (we get file size from OST anyways).
543 attr->ia_valid &= ~ATTR_SIZE;
547 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
549 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
550 attr, NULL, 0, &request);
552 CERROR("mdc_setattr fails: err = %d\n", err);
554 ptlrpc_req_finished(request);
556 if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_MTIME_SET)) {
557 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
562 CDEBUG(D_INODE, "no lsm: not setting mtime on OSTs\n");
566 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
567 inode->i_ino, attr->ia_mtime);
568 oa.o_id = lsm->lsm_object_id;
570 oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMTIME;
571 oa.o_mtime = attr->ia_mtime;
572 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
574 CERROR("obd_setattr fails: rc=%d\n", err);
582 int ll_setattr(struct dentry *de, struct iattr *attr)
584 int rc = inode_change_ok(de->d_inode, attr);
585 CDEBUG(D_VFSTRACE, "VFS Op:name=%s\n", de->d_name.name);
589 return ll_inode_setattr(de->d_inode, attr, 1);
592 static int ll_statfs(struct super_block *sb, struct statfs *sfs)
594 struct ll_sb_info *sbi = ll_s2sbi(sb);
595 struct obd_statfs osfs;
599 CDEBUG(D_VFSTRACE, "VFS Op:\n");
600 memset(sfs, 0, sizeof(*sfs));
601 rc = obd_statfs(&sbi->ll_mdc_conn, &osfs);
602 statfs_unpack(sfs, &osfs);
604 CERROR("mdc_statfs fails: rc = %d\n", rc);
606 CDEBUG(D_SUPER, "mdc_statfs shows blocks "LPU64"/"LPU64
607 " objects "LPU64"/"LPU64"\n",
608 osfs.os_bavail, osfs.os_blocks,
609 osfs.os_ffree, osfs.os_files);
611 /* temporary until mds_statfs returns statfs info for all OSTs */
613 rc = obd_statfs(&sbi->ll_osc_conn, &osfs);
615 CERROR("obd_statfs fails: rc = %d\n", rc);
618 CDEBUG(D_SUPER, "obd_statfs shows blocks "LPU64"/"LPU64
619 " objects "LPU64"/"LPU64"\n",
620 osfs.os_bavail, osfs.os_blocks,
621 osfs.os_ffree, osfs.os_files);
623 while (osfs.os_blocks > ~0UL) {
626 osfs.os_blocks >>= 1;
628 osfs.os_bavail >>= 1;
631 sfs->f_blocks = osfs.os_blocks;
632 sfs->f_bfree = osfs.os_bfree;
633 sfs->f_bavail = osfs.os_bavail;
635 /* If we don't have as many objects free on the OST as inodes
636 * on the MDS, we reduce the total number of inodes to
637 * compensate, so that the "inodes in use" number is correct.
639 if (osfs.os_ffree < (__u64)sfs->f_ffree) {
640 sfs->f_files = (sfs->f_files - sfs->f_ffree) +
642 sfs->f_ffree = osfs.os_ffree;
650 void dump_lsm(int level, struct lov_stripe_md *lsm)
652 CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic %#08x, "
653 "stripe_size %#08x, offset %u, stripe_count %u\n",
654 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
655 lsm->lsm_stripe_size, lsm->lsm_stripe_offset,
656 lsm->lsm_stripe_count);
659 void ll_update_inode(struct inode *inode, struct mds_body *body,
660 struct lov_stripe_md *lsm)
662 struct ll_inode_info *lli = ll_i2info(inode);
664 LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
666 if (lli->lli_smd == NULL) {
667 lli->lli_maxbytes = lsm->lsm_maxbytes;
668 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
669 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
672 if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
673 CERROR("lsm mismatch for inode %ld\n",
675 CERROR("lli_smd:\n");
676 dump_lsm(D_ERROR, lli->lli_smd);
678 dump_lsm(D_ERROR, lsm);
684 if (body->valid & OBD_MD_FLID)
685 inode->i_ino = body->ino;
686 if (body->valid & OBD_MD_FLATIME)
687 LTIME_S(inode->i_atime) = body->atime;
688 if (body->valid & OBD_MD_FLMTIME)
689 LTIME_S(inode->i_mtime) = body->mtime;
690 if (body->valid & OBD_MD_FLCTIME)
691 LTIME_S(inode->i_ctime) = body->ctime;
692 if (body->valid & OBD_MD_FLMODE)
693 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
694 if (body->valid & OBD_MD_FLTYPE)
695 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
696 if (body->valid & OBD_MD_FLUID)
697 inode->i_uid = body->uid;
698 if (body->valid & OBD_MD_FLGID)
699 inode->i_gid = body->gid;
700 if (body->valid & OBD_MD_FLFLAGS)
701 inode->i_flags = body->flags;
702 if (body->valid & OBD_MD_FLNLINK)
703 inode->i_nlink = body->nlink;
704 if (body->valid & OBD_MD_FLGENER)
705 inode->i_generation = body->generation;
706 if (body->valid & OBD_MD_FLRDEV)
707 inode->i_rdev = body->rdev;
708 if (body->valid & OBD_MD_FLSIZE)
709 inode->i_size = body->size;
710 if (body->valid & OBD_MD_FLBLOCKS)
711 inode->i_blocks = body->blocks;
714 static void ll_read_inode2(struct inode *inode, void *opaque)
716 struct ll_read_inode2_cookie *lic = opaque;
717 struct mds_body *body = lic->lic_body;
718 struct ll_inode_info *lli = ll_i2info(inode);
720 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
721 inode->i_generation, inode);
723 sema_init(&lli->lli_open_sem, 1);
724 spin_lock_init(&lli->lli_read_extent_lock);
725 INIT_LIST_HEAD(&lli->lli_read_extents);
726 ll_lldo_init(&lli->lli_dirty);
728 /* We default to 2T-4k until the LSM is created/read, at which point
729 * it'll be updated. */
730 lli->lli_maxbytes = LUSTRE_STRIPE_MAXBYTES;
732 LASSERT(!lli->lli_smd);
734 /* core attributes from the MDS first */
735 ll_update_inode(inode, body, lic->lic_lsm);
737 /* OIDEBUG(inode); */
739 if (S_ISREG(inode->i_mode)) {
740 inode->i_op = &ll_file_inode_operations;
741 inode->i_fop = &ll_file_operations;
742 inode->i_mapping->a_ops = &ll_aops;
744 } else if (S_ISDIR(inode->i_mode)) {
745 inode->i_op = &ll_dir_inode_operations;
746 inode->i_fop = &ll_dir_operations;
747 inode->i_mapping->a_ops = &ll_dir_aops;
749 } else if (S_ISLNK(inode->i_mode)) {
750 inode->i_op = &ll_fast_symlink_inode_operations;
753 inode->i_op = &ll_special_inode_operations;
754 init_special_inode(inode, inode->i_mode, inode->i_rdev);
759 void ll_umount_begin(struct super_block *sb)
761 struct ll_sb_info *sbi = ll_s2sbi(sb);
762 struct obd_device *obd;
763 struct obd_ioctl_data ioc_data = { 0 };
766 CDEBUG(D_VFSTRACE, "VFS Op:\n");
768 obd = class_conn2obd(&sbi->ll_mdc_conn);
769 obd->obd_no_recov = 1;
770 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_mdc_conn, sizeof ioc_data,
773 obd = class_conn2obd(&sbi->ll_osc_conn);
774 obd->obd_no_recov = 1;
775 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_osc_conn, sizeof ioc_data,
778 /* Really, we'd like to wait until there are no requests outstanding,
779 * and then continue. For now, we just invalidate the requests,
780 * schedule, and hope.
787 /* exported operations */
788 struct super_operations ll_super_operations =
790 read_inode2: ll_read_inode2,
791 clear_inode: ll_clear_inode,
792 // delete_inode: ll_delete_inode,
793 put_super: ll_put_super,
795 umount_begin: ll_umount_begin
798 static struct file_system_type lustre_lite_fs_type = {
801 read_super: ll_read_super,
805 static int __init init_lustre_lite(void)
807 printk(KERN_INFO "Lustre Lite Client File System; "
808 "info@clusterfs.com\n");
809 ll_file_data_slab = kmem_cache_create("ll_file_data",
810 sizeof(struct ll_file_data), 0,
811 SLAB_HWCACHE_ALIGN, NULL, NULL);
812 if (ll_file_data_slab == NULL)
815 proc_lustre_fs_root = proc_lustre_root ? proc_mkdir("llite", proc_lustre_root) : NULL;
817 return register_filesystem(&lustre_lite_fs_type);
820 static void __exit exit_lustre_lite(void)
822 unregister_filesystem(&lustre_lite_fs_type);
823 kmem_cache_destroy(ll_file_data_slab);
825 if (proc_lustre_fs_root) {
826 lprocfs_remove(proc_lustre_fs_root);
827 proc_lustre_fs_root = NULL;
831 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
832 MODULE_DESCRIPTION("Lustre Lite Client File System");
833 MODULE_LICENSE("GPL");
835 module_init(init_lustre_lite);
836 module_exit(exit_lustre_lite);