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 #include <asm/statfs.h>
39 kmem_cache_t *ll_file_data_slab;
40 extern struct address_space_operations ll_aops;
41 extern struct address_space_operations ll_dir_aops;
42 struct super_operations ll_super_operations;
44 /* /proc/lustre/llite root that tracks llite mount points */
45 struct proc_dir_entry *proc_lustre_fs_root = NULL;
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_init_inodecache(void);
52 extern void ll_destroy_inodecache(void);
53 extern int ll_recover(struct recovd_data *, int);
54 extern int ll_commitcbd_setup(struct ll_sb_info *);
55 extern int ll_commitcbd_cleanup(struct ll_sb_info *);
56 int ll_read_inode2(struct inode *inode, void *opaque);
58 extern int ll_proc_namespace(struct super_block* sb, char* osc, char* mdc);
60 static char *ll_read_opt(const char *opt, char *data)
66 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
67 if (strncmp(opt, data, strlen(opt)))
69 if ((value = strchr(data, '=')) == NULL)
73 OBD_ALLOC(retval, strlen(value) + 1);
75 CERROR("out of memory!\n");
79 memcpy(retval, value, strlen(value)+1);
80 CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
84 static int ll_set_opt(const char *opt, char *data, int fl)
88 CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
89 if (strncmp(opt, data, strlen(opt)))
95 static void ll_options(char *options, char **ost, char **mds, int *flags)
97 char *opt_ptr = options;
106 while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
107 CDEBUG(D_SUPER, "this_char %s\n", this_char);
108 if ((!*ost && (*ost = ll_read_opt("osc", this_char)))||
109 (!*mds && (*mds = ll_read_opt("mdc", this_char)))||
110 (!(*flags & LL_SBI_NOLCK) &&
111 ((*flags) = (*flags) |
112 ll_set_opt("nolock", this_char, LL_SBI_NOLCK))))
119 #define log2(n) ffz(~(n))
123 static int ll_fill_super(struct super_block *sb, void *data, int silent)
125 struct inode *root = 0;
126 struct obd_device *obd;
127 struct ll_sb_info *sbi;
131 struct ll_fid rootfid;
132 struct obd_statfs osfs;
133 struct ptlrpc_request *request = NULL;
134 struct ptlrpc_connection *mdc_conn;
135 struct ll_read_inode2_cookie lic;
137 struct obd_uuid param_uuid;
140 CDEBUG(D_VFSTRACE, "VFS Op:\n");
142 OBD_ALLOC(sbi, sizeof(*sbi));
146 INIT_LIST_HEAD(&sbi->ll_conn_chain);
147 INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list);
148 generate_random_uuid(uuid);
149 class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
153 ll_options(data, &osc, &mdc, &sbi->ll_flags);
157 GOTO(out_free, sb = NULL);
162 GOTO(out_free, sb = NULL);
165 strncpy(param_uuid.uuid, mdc, sizeof(param_uuid.uuid));
166 obd = class_uuid2obd(¶m_uuid);
168 CERROR("MDC %s: not setup or attached\n", mdc);
169 GOTO(out_free, sb = NULL);
172 err = obd_connect(&sbi->ll_mdc_conn, obd, &sbi->ll_sb_uuid);
174 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
175 GOTO(out_free, sb = NULL);
178 mdc_conn = sbi2mdc(sbi)->cl_import->imp_connection;
179 strncpy(param_uuid.uuid, osc, sizeof(param_uuid.uuid));
181 obd = class_uuid2obd(¶m_uuid);
183 CERROR("OSC %s: not setup or attached\n", osc);
184 GOTO(out_mdc, sb = NULL);
187 err = obd_connect(&sbi->ll_osc_conn, obd, &sbi->ll_sb_uuid);
189 CERROR("cannot connect to %s: rc = %d\n", osc, err);
190 GOTO(out_mdc, sb = NULL);
193 err = mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
195 CERROR("cannot mds_connect: rc = %d\n", err);
196 GOTO(out_osc, sb = NULL);
198 CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
199 sbi->ll_rootino = rootfid.id;
201 memset(&osfs, 0, sizeof(osfs));
202 err = obd_statfs(&sbi->ll_mdc_conn, &osfs);
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;
208 sb->s_op = &ll_super_operations;
211 * XXX: move this to after cbd setup? */
212 err = mdc_getattr(&sbi->ll_mdc_conn, &rootfid,
213 OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
215 CERROR("mdc_getattr failed for root: rc = %d\n", err);
216 GOTO(out_osc, sb = NULL);
219 /* initialize committed transaction callback daemon */
220 spin_lock_init(&sbi->ll_commitcbd_lock);
221 init_waitqueue_head(&sbi->ll_commitcbd_waitq);
222 init_waitqueue_head(&sbi->ll_commitcbd_ctl_waitq);
223 sbi->ll_commitcbd_flags = 0;
224 err = ll_commitcbd_setup(sbi);
226 CERROR("failed to start commit callback daemon: rc = %d\n",err);
227 ptlrpc_req_finished (request);
228 GOTO(out_osc, sb = NULL);
231 lic.lic_body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*lic.lic_body));
232 LASSERT (lic.lic_body != NULL); /* checked by mdc_getattr() */
233 LASSERT_REPSWABBED (request, 0); /* swabbed by mdc_getattr() */
237 root = iget5_locked(sb, sbi->ll_rootino, NULL,
238 ll_read_inode2, &lic);
240 ptlrpc_req_finished(request);
242 if (root == NULL || is_bad_inode(root)) {
243 /* XXX might need iput() for bad inode */
244 CERROR("lustre_lite: bad iget5 for root\n");
245 GOTO(out_cbd, sb = NULL);
248 sb->s_root = d_alloc_root(root);
249 root->i_state &= ~(I_LOCK | I_NEW);
251 if (proc_lustre_fs_root) {
252 err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
255 CERROR("could not register mount in /proc/lustre");
260 OBD_FREE(mdc, strlen(mdc) + 1);
262 OBD_FREE(osc, strlen(osc) + 1);
268 ll_commitcbd_cleanup(sbi);
270 obd_disconnect(&sbi->ll_osc_conn, 0);
272 obd_disconnect(&sbi->ll_mdc_conn, 0);
274 OBD_FREE(sbi, sizeof(*sbi));
277 } /* ll_fill_super */
280 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
282 struct ptlrpc_request *request = NULL;
283 struct ll_sb_info *sbi = ll_i2sbi(inode);
284 struct mdc_op_data op_data;
287 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
289 if ((attr->ia_valid & ATTR_SIZE)) {
290 /* writeback uses inode->i_size to determine how far out
291 * its cached pages go. ll_truncate gets a PW lock, canceling
292 * our lock, _after_ it has updated i_size. this can confuse
293 * us into zero extending the file to the newly truncated
294 * size, and this has bad implications for a racing o_append.
295 * if we're extending our size we need to flush the pages
296 * with the correct i_size before vmtruncate stomps on
297 * the new i_size. again, this can only find pages to
298 * purge if the PW lock that generated them is still held.
300 if ( attr->ia_size > inode->i_size ) {
301 filemap_fdatasync(inode->i_mapping);
302 filemap_fdatawait(inode->i_mapping);
304 err = vmtruncate(inode, attr->ia_size);
309 /* Don't send size changes to MDS to avoid "fast EA" problems, and
310 * also avoid a pointless RPC (we get file size from OST anyways).
312 attr->ia_valid &= ~ATTR_SIZE;
316 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
318 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
319 attr, NULL, 0, &request);
321 CERROR("mdc_setattr fails: err = %d\n", err);
323 ptlrpc_req_finished(request);
325 if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_MTIME_SET) {
326 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
330 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
331 inode->i_ino, attr->ia_mtime);
332 oa.o_id = lsm->lsm_object_id;
334 oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMTIME;
335 oa.o_mtime = LTIME_S(attr->ia_mtime);
336 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
338 CERROR("obd_setattr fails: rc=%d\n", err);
345 struct super_block * ll_get_sb(struct file_system_type *fs_type,
346 int flags, char *devname, void * data)
348 return get_sb_nodev(fs_type, flags, data, ll_fill_super);
351 static void ll_put_super(struct super_block *sb)
353 struct ll_sb_info *sbi = ll_s2sbi(sb);
354 struct list_head *tmp, *next;
355 struct ll_fid rootfid;
357 CDEBUG(D_VFSTRACE, "VFS Op:\n");
359 list_del(&sbi->ll_conn_chain);
360 ll_commitcbd_cleanup(sbi);
361 obd_disconnect(&sbi->ll_osc_conn, 0);
363 /* NULL request to force sync on the MDS, and get the last_committed
364 * value to flush remaining RPCs from the pending queue on client.
366 * XXX This should be an mdc_sync() call to sync the whole MDS fs,
367 * which we can call for other reasons as well.
369 mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
371 if (sbi->ll_proc_root) {
372 lprocfs_remove(sbi->ll_proc_root);
373 sbi->ll_proc_root = NULL;
376 obd_disconnect(&sbi->ll_mdc_conn, 0);
378 spin_lock(&dcache_lock);
379 list_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list){
380 struct dentry *dentry = list_entry(tmp, struct dentry, d_hash);
381 shrink_dcache_parent(dentry);
383 spin_unlock(&dcache_lock);
385 OBD_FREE(sbi, sizeof(*sbi));
390 static void ll_clear_inode(struct inode *inode)
392 struct ll_sb_info *sbi = ll_i2sbi(inode);
393 struct ll_inode_info *lli = ll_i2info(inode);
396 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
398 #warning "Is there a reason we don't do this in 2.5, but we do in 2.4?"
400 rc = ll_mdc_cancel_unused(&sbi->ll_mdc_conn, inode, LDLM_FL_NO_CALLBACK);
402 CERROR("ll_mdc_cancel_unused: %d\n", rc);
403 /* XXX FIXME do something dramatic */
407 rc = obd_cancel_unused(&sbi->ll_osc_conn, lli->lli_smd, 0);
409 CERROR("obd_cancel_unused: %d\n", rc);
410 /* XXX FIXME do something dramatic */
415 if (atomic_read(&inode->i_count) != 0)
416 CERROR("clearing in-use inode %lu: count = %d\n",
417 inode->i_ino, atomic_read(&inode->i_count));
420 obd_free_memmd(&sbi->ll_osc_conn, &lli->lli_smd);
424 if (lli->lli_symlink_name) {
425 OBD_FREE(lli->lli_symlink_name,strlen(lli->lli_symlink_name)+1);
426 lli->lli_symlink_name = NULL;
433 static void ll_delete_inode(struct inode *inode)
436 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
437 if (S_ISREG(inode->i_mode)) {
440 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
442 /* mcreate with no open */
446 if (lsm->lsm_object_id == 0) {
447 CERROR("This really happens\n");
448 /* No obdo was ever created */
456 oa->o_id = lsm->lsm_object_id;
457 oa->o_mode = inode->i_mode;
458 oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE;
460 err = obd_destroy(ll_i2obdconn(inode), oa, lsm);
463 CDEBUG(D_SUPER, "obd destroy objid "LPX64" error %d\n",
464 lsm->lsm_object_id, err);
472 /* like inode_setattr, but doesn't mark the inode dirty */
473 static int ll_attr2inode(struct inode * inode, struct iattr * attr, int trunc)
475 unsigned int ia_valid = attr->ia_valid;
478 if ((ia_valid & ATTR_SIZE) && trunc) {
479 if (attr->ia_size > ll_file_maxbytes(inode)) {
483 error = vmtruncate(inode, attr->ia_size);
486 } else if (ia_valid & ATTR_SIZE)
487 inode->i_size = attr->ia_size;
489 if (ia_valid & ATTR_UID)
490 inode->i_uid = attr->ia_uid;
491 if (ia_valid & ATTR_GID)
492 inode->i_gid = attr->ia_gid;
493 if (ia_valid & ATTR_ATIME)
494 inode->i_atime = attr->ia_atime;
495 if (ia_valid & ATTR_MTIME)
496 inode->i_mtime = attr->ia_mtime;
497 if (ia_valid & ATTR_CTIME)
498 inode->i_ctime = attr->ia_ctime;
499 if (ia_valid & ATTR_MODE) {
500 inode->i_mode = attr->ia_mode;
501 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
502 inode->i_mode &= ~S_ISGID;
508 int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc)
510 struct ptlrpc_request *request = NULL;
511 struct ll_sb_info *sbi = ll_i2sbi(inode);
516 /* change incore inode */
517 err = ll_attr2inode(inode, attr, do_trunc);
521 /* Don't send size changes to MDS to avoid "fast EA" problems, and
522 * also avoid a pointless RPC (we get file size from OST anyways).
524 attr->ia_valid &= ~ATTR_SIZE;
525 if (attr->ia_valid) {
526 struct mdc_op_data op_data;
528 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
530 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
531 attr, NULL, 0, &request);
533 CERROR("mdc_setattr fails: err = %d\n", err);
535 ptlrpc_req_finished(request);
536 if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_MTIME_SET) {
537 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
541 CDEBUG(D_ERROR, "setting mtime on OST\n");
542 oa.o_id = lsm->lsm_object_id;
544 oa.o_valid = OBD_MD_FLID |OBD_MD_FLTYPE |OBD_MD_FLMTIME;
545 oa.o_mtime = LTIME_S(attr->ia_mtime);
546 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
548 CERROR("obd_setattr fails: rc=%d\n", err);
558 int ll_setattr(struct dentry *de, struct iattr *attr)
560 int rc = inode_change_ok(de->d_inode, attr);
561 CDEBUG(D_VFSTRACE, "VFS Op:name=%s\n", de->d_name.name);
565 return ll_inode_setattr(de->d_inode, attr, 1);
568 static int ll_statfs(struct super_block *sb, struct statfs *sfs)
570 struct ll_sb_info *sbi = ll_s2sbi(sb);
571 struct obd_statfs osfs;
574 CDEBUG(D_VFSTRACE, "VFS Op:\n");
576 memset(sfs, 0, sizeof(*sfs));
577 rc = obd_statfs(&sbi->ll_mdc_conn, &osfs);
578 statfs_unpack(sfs, &osfs);
580 CERROR("mdc_statfs fails: rc = %d\n", rc);
582 CDEBUG(D_SUPER, "mdc_statfs shows blocks "LPU64"/"LPU64
583 " objects "LPU64"/"LPU64"\n",
584 osfs.os_bavail, osfs.os_blocks,
585 osfs.os_ffree, osfs.os_files);
587 /* temporary until mds_statfs returns statfs info for all OSTs */
589 rc = obd_statfs(&sbi->ll_osc_conn, &osfs);
591 CERROR("obd_statfs fails: rc = %d\n", rc);
594 CDEBUG(D_SUPER, "obd_statfs shows blocks "LPU64"/"LPU64
595 " objects "LPU64"/"LPU64"\n",
596 osfs.os_bavail, osfs.os_blocks,
597 osfs.os_ffree, osfs.os_files);
599 while (osfs.os_blocks > ~0UL) {
602 osfs.os_blocks >>= 1;
604 osfs.os_bavail >>= 1;
606 sfs->f_blocks = osfs.os_blocks;
607 sfs->f_bfree = osfs.os_bfree;
608 sfs->f_bavail = osfs.os_bavail;
609 if (osfs.os_ffree < (__u64)sfs->f_ffree) {
610 sfs->f_files = (sfs->f_files - sfs->f_ffree) +
612 sfs->f_ffree = osfs.os_ffree;
620 void ll_update_inode(struct inode *inode, struct mds_body *body,
621 struct lov_stripe_md *lsm)
623 struct ll_inode_info *lli = ll_i2info(inode);
625 LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
627 if (lli->lli_smd == NULL) {
629 lli->lli_maxbytes = lsm->lsm_maxbytes;
630 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
631 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
633 LASSERT (!memcmp (lli->lli_smd, lsm, sizeof (*lsm)));
637 if (body->valid & OBD_MD_FLID)
638 inode->i_ino = body->ino;
639 if (body->valid & OBD_MD_FLATIME)
640 LTIME_S(inode->i_atime) = body->atime;
641 if (body->valid & OBD_MD_FLMTIME)
642 LTIME_S(inode->i_mtime) = body->mtime;
643 if (body->valid & OBD_MD_FLCTIME)
644 LTIME_S(inode->i_ctime) = body->ctime;
645 if (body->valid & OBD_MD_FLMODE)
646 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
647 if (body->valid & OBD_MD_FLTYPE)
648 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
649 if (body->valid & OBD_MD_FLUID)
650 inode->i_uid = body->uid;
651 if (body->valid & OBD_MD_FLGID)
652 inode->i_gid = body->gid;
653 if (body->valid & OBD_MD_FLFLAGS)
654 inode->i_flags = body->flags;
655 if (body->valid & OBD_MD_FLNLINK)
656 inode->i_nlink = body->nlink;
657 if (body->valid & OBD_MD_FLGENER)
658 inode->i_generation = body->generation;
659 if (body->valid & OBD_MD_FLRDEV)
660 inode->i_rdev = to_kdev_t(body->rdev);
661 if (body->valid & OBD_MD_FLSIZE)
662 inode->i_size = body->size;
663 if (body->valid & OBD_MD_FLBLOCKS)
664 inode->i_blocks = body->blocks;
667 int ll_read_inode2(struct inode *inode, void *opaque)
669 struct ll_read_inode2_cookie *lic = opaque;
670 struct mds_body *body = lic->lic_body;
671 struct ll_inode_info *lli = ll_i2info(inode);
674 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
676 sema_init(&lli->lli_open_sem, 1);
677 /* these are 2.4 only, but putting them here for consistency.. */
678 spin_lock_init(&lli->lli_read_extent_lock);
679 INIT_LIST_HEAD(&lli->lli_read_extents);
680 ll_lldo_init(&lli->lli_dirty);
682 lli->lli_maxbytes = LUSTRE_STRIPE_MAXBYTES;
684 LASSERT(!lli->lli_smd);
686 /* core attributes first */
687 ll_update_inode(inode, body, lic ? lic->lic_lsm : NULL);
689 /* OIDEBUG(inode); */
691 if (S_ISREG(inode->i_mode)) {
692 inode->i_op = &ll_file_inode_operations;
693 inode->i_fop = &ll_file_operations;
694 inode->i_mapping->a_ops = &ll_aops;
696 } else if (S_ISDIR(inode->i_mode)) {
697 inode->i_op = &ll_dir_inode_operations;
698 inode->i_fop = &ll_dir_operations;
699 inode->i_mapping->a_ops = &ll_dir_aops;
701 } else if (S_ISLNK(inode->i_mode)) {
702 inode->i_op = &ll_fast_symlink_inode_operations;
705 inode->i_op = &ll_special_inode_operations;
706 init_special_inode(inode, inode->i_mode,
707 kdev_t_to_nr(inode->i_rdev));
715 void ll_umount_begin(struct super_block *sb)
717 struct ll_sb_info *sbi = ll_s2sbi(sb);
718 struct obd_device *obd;
719 struct obd_ioctl_data ioc_data = { 0 };
722 CDEBUG(D_VFSTRACE, "VFS Op:\n");
724 obd = class_conn2obd(&sbi->ll_mdc_conn);
725 obd->obd_no_recov = 1;
726 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_mdc_conn, sizeof ioc_data,
729 obd = class_conn2obd(&sbi->ll_osc_conn);
730 obd->obd_no_recov = 1;
731 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_osc_conn, sizeof ioc_data,
734 /* Really, we'd like to wait until there are no requests outstanding,
735 * and then continue. For now, we just invalidate the requests,
736 * schedule, and hope.
743 static kmem_cache_t *ll_inode_cachep;
745 static struct inode *ll_alloc_inode(struct super_block *sb)
747 struct ll_inode_info *lli;
748 OBD_SLAB_ALLOC(lli, ll_inode_cachep, SLAB_KERNEL, sizeof *lli);
752 memset(lli, 0, (char *)&lli->lli_vfs_inode - (char *)lli);
753 sema_init(&lli->lli_open_sem, 1);
754 init_MUTEX(&lli->lli_size_valid_sem);
755 lli->lli_maxbytes = LUSTRE_STRIPE_MAXBYTES;
757 return &lli->lli_vfs_inode;
760 static void ll_destroy_inode(struct inode *inode)
762 OBD_SLAB_FREE(ll_inode_cachep, ll_i2info(inode),
763 sizeof(struct ll_inode_info));
766 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
768 struct ll_inode_info *lli = foo;
770 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
771 SLAB_CTOR_CONSTRUCTOR)
772 inode_init_once(&lli->lli_vfs_inode);
775 int ll_init_inodecache(void)
777 ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
778 sizeof(struct ll_inode_info),
779 0, SLAB_HWCACHE_ALIGN,
781 if (ll_inode_cachep == NULL)
786 void ll_destroy_inodecache(void)
788 if (kmem_cache_destroy(ll_inode_cachep))
789 CERROR("ll_inode_cache: not all structures were freed\n");
794 /* exported operations */
795 struct super_operations ll_super_operations =
797 alloc_inode: ll_alloc_inode,
798 destroy_inode: ll_destroy_inode,
799 clear_inode: ll_clear_inode,
800 // delete_inode: ll_delete_inode,
801 put_super: ll_put_super,
803 umount_begin: ll_umount_begin
807 struct file_system_type lustre_lite_fs_type = {
808 .owner = THIS_MODULE,
809 .name = "lustre_lite",
811 .kill_sb = kill_anon_super,
814 static int __init init_lustre_lite(void)
817 printk(KERN_INFO "Lustre Lite Client File System; "
818 "info@clusterfs.com\n");
819 rc = ll_init_inodecache();
822 ll_file_data_slab = kmem_cache_create("ll_file_data",
823 sizeof(struct ll_file_data), 0,
824 SLAB_HWCACHE_ALIGN, NULL, NULL);
825 if (ll_file_data_slab == NULL) {
826 ll_destroy_inodecache();
830 proc_lustre_fs_root = proc_lustre_root ?
831 proc_mkdir("llite", proc_lustre_root) : NULL;
833 return register_filesystem(&lustre_lite_fs_type);
836 static void __exit exit_lustre_lite(void)
838 unregister_filesystem(&lustre_lite_fs_type);
839 ll_destroy_inodecache();
840 kmem_cache_destroy(ll_file_data_slab);
841 if (proc_lustre_fs_root) {
842 lprocfs_remove(proc_lustre_fs_root);
843 proc_lustre_fs_root = NULL;
847 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
848 MODULE_DESCRIPTION("Lustre Lite Client File System");
849 MODULE_LICENSE("GPL");
851 module_init(init_lustre_lite);
852 module_exit(exit_lustre_lite);