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 lprocfs_unregister_mountpoint(sbi);
275 OBD_FREE(sbi, sizeof(*sbi));
278 } /* ll_fill_super */
281 int ll_setattr_raw(struct inode *inode, struct iattr *attr)
283 struct ptlrpc_request *request = NULL;
284 struct ll_sb_info *sbi = ll_i2sbi(inode);
285 struct mdc_op_data op_data;
288 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
290 LPROC_COUNTER_INODE_INCBY1(inode, LPROC_LL_SETATTR);
291 if ((attr->ia_valid & ATTR_SIZE)) {
292 /* writeback uses inode->i_size to determine how far out
293 * its cached pages go. ll_truncate gets a PW lock, canceling
294 * our lock, _after_ it has updated i_size. this can confuse
295 * us into zero extending the file to the newly truncated
296 * size, and this has bad implications for a racing o_append.
297 * if we're extending our size we need to flush the pages
298 * with the correct i_size before vmtruncate stomps on
299 * the new i_size. again, this can only find pages to
300 * purge if the PW lock that generated them is still held.
302 if ( attr->ia_size > inode->i_size ) {
303 filemap_fdatasync(inode->i_mapping);
304 filemap_fdatawait(inode->i_mapping);
306 err = vmtruncate(inode, attr->ia_size);
311 /* Don't send size changes to MDS to avoid "fast EA" problems, and
312 * also avoid a pointless RPC (we get file size from OST anyways).
314 attr->ia_valid &= ~ATTR_SIZE;
318 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
320 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
321 attr, NULL, 0, &request);
323 CERROR("mdc_setattr fails: err = %d\n", err);
325 ptlrpc_req_finished(request);
327 if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_MTIME_SET) {
328 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
332 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
333 inode->i_ino, attr->ia_mtime);
334 oa.o_id = lsm->lsm_object_id;
336 oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMTIME;
337 oa.o_mtime = LTIME_S(attr->ia_mtime);
338 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
340 CERROR("obd_setattr fails: rc=%d\n", err);
347 struct super_block * ll_get_sb(struct file_system_type *fs_type,
348 int flags, char *devname, void * data)
350 return get_sb_nodev(fs_type, flags, data, ll_fill_super);
353 static void ll_put_super(struct super_block *sb)
355 struct ll_sb_info *sbi = ll_s2sbi(sb);
356 struct list_head *tmp, *next;
357 struct ll_fid rootfid;
359 CDEBUG(D_VFSTRACE, "VFS Op:\n");
361 list_del(&sbi->ll_conn_chain);
362 ll_commitcbd_cleanup(sbi);
363 obd_disconnect(&sbi->ll_osc_conn, 0);
365 /* NULL request to force sync on the MDS, and get the last_committed
366 * value to flush remaining RPCs from the pending queue on client.
368 * XXX This should be an mdc_sync() call to sync the whole MDS fs,
369 * which we can call for other reasons as well.
371 mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
373 lprocfs_unregister_mountpoint(sbi);
374 if (sbi->ll_proc_root) {
375 lprocfs_remove(sbi->ll_proc_root);
376 sbi->ll_proc_root = NULL;
379 obd_disconnect(&sbi->ll_mdc_conn, 0);
381 spin_lock(&dcache_lock);
382 list_for_each_safe(tmp, next, &sbi->ll_orphan_dentry_list){
383 struct dentry *dentry = list_entry(tmp, struct dentry, d_hash);
384 shrink_dcache_parent(dentry);
386 spin_unlock(&dcache_lock);
388 OBD_FREE(sbi, sizeof(*sbi));
393 static void ll_clear_inode(struct inode *inode)
395 struct ll_sb_info *sbi = ll_i2sbi(inode);
396 struct ll_inode_info *lli = ll_i2info(inode);
399 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
401 #warning "Is there a reason we don't do this in 2.5, but we do in 2.4?"
403 rc = ll_mdc_cancel_unused(&sbi->ll_mdc_conn, inode, LDLM_FL_NO_CALLBACK);
405 CERROR("ll_mdc_cancel_unused: %d\n", rc);
406 /* XXX FIXME do something dramatic */
410 rc = obd_cancel_unused(&sbi->ll_osc_conn, lli->lli_smd, 0);
412 CERROR("obd_cancel_unused: %d\n", rc);
413 /* XXX FIXME do something dramatic */
418 if (atomic_read(&inode->i_count) != 0)
419 CERROR("clearing in-use inode %lu: count = %d\n",
420 inode->i_ino, atomic_read(&inode->i_count));
423 obd_free_memmd(&sbi->ll_osc_conn, &lli->lli_smd);
427 if (lli->lli_symlink_name) {
428 OBD_FREE(lli->lli_symlink_name,strlen(lli->lli_symlink_name)+1);
429 lli->lli_symlink_name = NULL;
436 static void ll_delete_inode(struct inode *inode)
439 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
440 if (S_ISREG(inode->i_mode)) {
443 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
445 /* mcreate with no open */
449 if (lsm->lsm_object_id == 0) {
450 CERROR("This really happens\n");
451 /* No obdo was ever created */
459 oa->o_id = lsm->lsm_object_id;
460 oa->o_mode = inode->i_mode;
461 oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE;
463 err = obd_destroy(ll_i2obdconn(inode), oa, lsm);
466 CDEBUG(D_SUPER, "obd destroy objid "LPX64" error %d\n",
467 lsm->lsm_object_id, err);
475 /* like inode_setattr, but doesn't mark the inode dirty */
476 static int ll_attr2inode(struct inode * inode, struct iattr * attr, int trunc)
478 unsigned int ia_valid = attr->ia_valid;
481 if ((ia_valid & ATTR_SIZE) && trunc) {
482 if (attr->ia_size > ll_file_maxbytes(inode)) {
486 error = vmtruncate(inode, attr->ia_size);
489 } else if (ia_valid & ATTR_SIZE)
490 inode->i_size = attr->ia_size;
492 if (ia_valid & ATTR_UID)
493 inode->i_uid = attr->ia_uid;
494 if (ia_valid & ATTR_GID)
495 inode->i_gid = attr->ia_gid;
496 if (ia_valid & ATTR_ATIME)
497 inode->i_atime = attr->ia_atime;
498 if (ia_valid & ATTR_MTIME)
499 inode->i_mtime = attr->ia_mtime;
500 if (ia_valid & ATTR_CTIME)
501 inode->i_ctime = attr->ia_ctime;
502 if (ia_valid & ATTR_MODE) {
503 inode->i_mode = attr->ia_mode;
504 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
505 inode->i_mode &= ~S_ISGID;
511 int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc)
513 struct ptlrpc_request *request = NULL;
514 struct ll_sb_info *sbi = ll_i2sbi(inode);
519 /* change incore inode */
520 err = ll_attr2inode(inode, attr, do_trunc);
524 /* Don't send size changes to MDS to avoid "fast EA" problems, and
525 * also avoid a pointless RPC (we get file size from OST anyways).
527 attr->ia_valid &= ~ATTR_SIZE;
528 if (attr->ia_valid) {
529 struct mdc_op_data op_data;
531 ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0);
533 err = mdc_setattr(&sbi->ll_mdc_conn, &op_data,
534 attr, NULL, 0, &request);
536 CERROR("mdc_setattr fails: err = %d\n", err);
538 ptlrpc_req_finished(request);
539 if (S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_MTIME_SET) {
540 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
544 CDEBUG(D_ERROR, "setting mtime on OST\n");
545 oa.o_id = lsm->lsm_object_id;
547 oa.o_valid = OBD_MD_FLID |OBD_MD_FLTYPE |OBD_MD_FLMTIME;
548 oa.o_mtime = LTIME_S(attr->ia_mtime);
549 err2 = obd_setattr(&sbi->ll_osc_conn, &oa, lsm, NULL);
551 CERROR("obd_setattr fails: rc=%d\n", err);
561 int ll_setattr(struct dentry *de, struct iattr *attr)
563 int rc = inode_change_ok(de->d_inode, attr);
564 CDEBUG(D_VFSTRACE, "VFS Op:name=%s\n", de->d_name.name);
568 LPROC_COUNTER_INODE_INCBY1((de->d_inode), LPROC_LL_SETATTR);
569 return ll_inode_setattr(de->d_inode, attr, 1);
572 static int ll_statfs(struct super_block *sb, struct statfs *sfs)
574 struct ll_sb_info *sbi = ll_s2sbi(sb);
575 struct obd_statfs osfs;
578 CDEBUG(D_VFSTRACE, "VFS Op:\n");
580 LPROC_COUNTER_SBI_INCBY1(sbi, LPROC_LL_STAFS);
581 memset(sfs, 0, sizeof(*sfs));
582 rc = obd_statfs(&sbi->ll_mdc_conn, &osfs);
583 statfs_unpack(sfs, &osfs);
585 CERROR("mdc_statfs fails: rc = %d\n", rc);
587 CDEBUG(D_SUPER, "mdc_statfs shows blocks "LPU64"/"LPU64
588 " objects "LPU64"/"LPU64"\n",
589 osfs.os_bavail, osfs.os_blocks,
590 osfs.os_ffree, osfs.os_files);
592 /* temporary until mds_statfs returns statfs info for all OSTs */
594 rc = obd_statfs(&sbi->ll_osc_conn, &osfs);
596 CERROR("obd_statfs fails: rc = %d\n", rc);
599 CDEBUG(D_SUPER, "obd_statfs shows blocks "LPU64"/"LPU64
600 " objects "LPU64"/"LPU64"\n",
601 osfs.os_bavail, osfs.os_blocks,
602 osfs.os_ffree, osfs.os_files);
604 while (osfs.os_blocks > ~0UL) {
607 osfs.os_blocks >>= 1;
609 osfs.os_bavail >>= 1;
611 sfs->f_blocks = osfs.os_blocks;
612 sfs->f_bfree = osfs.os_bfree;
613 sfs->f_bavail = osfs.os_bavail;
614 if (osfs.os_ffree < (__u64)sfs->f_ffree) {
615 sfs->f_files = (sfs->f_files - sfs->f_ffree) +
617 sfs->f_ffree = osfs.os_ffree;
625 void ll_update_inode(struct inode *inode, struct mds_body *body,
626 struct lov_stripe_md *lsm)
628 struct ll_inode_info *lli = ll_i2info(inode);
630 LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
632 if (lli->lli_smd == NULL) {
634 lli->lli_maxbytes = lsm->lsm_maxbytes;
635 if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
636 lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
638 LASSERT (!memcmp (lli->lli_smd, lsm, sizeof (*lsm)));
642 if (body->valid & OBD_MD_FLID)
643 inode->i_ino = body->ino;
644 if (body->valid & OBD_MD_FLATIME)
645 LTIME_S(inode->i_atime) = body->atime;
646 if (body->valid & OBD_MD_FLMTIME)
647 LTIME_S(inode->i_mtime) = body->mtime;
648 if (body->valid & OBD_MD_FLCTIME)
649 LTIME_S(inode->i_ctime) = body->ctime;
650 if (body->valid & OBD_MD_FLMODE)
651 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
652 if (body->valid & OBD_MD_FLTYPE)
653 inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
654 if (body->valid & OBD_MD_FLUID)
655 inode->i_uid = body->uid;
656 if (body->valid & OBD_MD_FLGID)
657 inode->i_gid = body->gid;
658 if (body->valid & OBD_MD_FLFLAGS)
659 inode->i_flags = body->flags;
660 if (body->valid & OBD_MD_FLNLINK)
661 inode->i_nlink = body->nlink;
662 if (body->valid & OBD_MD_FLGENER)
663 inode->i_generation = body->generation;
664 if (body->valid & OBD_MD_FLRDEV)
665 inode->i_rdev = to_kdev_t(body->rdev);
666 if (body->valid & OBD_MD_FLSIZE)
667 inode->i_size = body->size;
668 if (body->valid & OBD_MD_FLBLOCKS)
669 inode->i_blocks = body->blocks;
672 int ll_read_inode2(struct inode *inode, void *opaque)
674 struct ll_read_inode2_cookie *lic = opaque;
675 struct mds_body *body = lic->lic_body;
676 struct ll_inode_info *lli = ll_i2info(inode);
679 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu\n", inode->i_ino);
681 sema_init(&lli->lli_open_sem, 1);
682 /* these are 2.4 only, but putting them here for consistency.. */
683 spin_lock_init(&lli->lli_read_extent_lock);
684 INIT_LIST_HEAD(&lli->lli_read_extents);
685 ll_lldo_init(&lli->lli_dirty);
687 lli->lli_maxbytes = LUSTRE_STRIPE_MAXBYTES;
689 LASSERT(!lli->lli_smd);
691 /* core attributes first */
692 ll_update_inode(inode, body, lic ? lic->lic_lsm : NULL);
694 /* OIDEBUG(inode); */
696 if (S_ISREG(inode->i_mode)) {
697 inode->i_op = &ll_file_inode_operations;
698 inode->i_fop = &ll_file_operations;
699 inode->i_mapping->a_ops = &ll_aops;
701 } else if (S_ISDIR(inode->i_mode)) {
702 inode->i_op = &ll_dir_inode_operations;
703 inode->i_fop = &ll_dir_operations;
704 inode->i_mapping->a_ops = &ll_dir_aops;
706 } else if (S_ISLNK(inode->i_mode)) {
707 inode->i_op = &ll_fast_symlink_inode_operations;
710 inode->i_op = &ll_special_inode_operations;
711 init_special_inode(inode, inode->i_mode,
712 kdev_t_to_nr(inode->i_rdev));
720 void ll_umount_begin(struct super_block *sb)
722 struct ll_sb_info *sbi = ll_s2sbi(sb);
723 struct obd_device *obd;
724 struct obd_ioctl_data ioc_data = { 0 };
727 CDEBUG(D_VFSTRACE, "VFS Op:\n");
729 obd = class_conn2obd(&sbi->ll_mdc_conn);
730 obd->obd_no_recov = 1;
731 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_mdc_conn, sizeof ioc_data,
734 obd = class_conn2obd(&sbi->ll_osc_conn);
735 obd->obd_no_recov = 1;
736 obd_iocontrol(IOC_OSC_SET_ACTIVE, &sbi->ll_osc_conn, sizeof ioc_data,
739 /* Really, we'd like to wait until there are no requests outstanding,
740 * and then continue. For now, we just invalidate the requests,
741 * schedule, and hope.
748 static kmem_cache_t *ll_inode_cachep;
750 static struct inode *ll_alloc_inode(struct super_block *sb)
752 struct ll_inode_info *lli;
753 LPROC_COUNTER_SBI_INCBY1((ll_s2sbi(sb)), LL_ALLOC_INODE);
754 OBD_SLAB_ALLOC(lli, ll_inode_cachep, SLAB_KERNEL, sizeof *lli);
758 memset(lli, 0, (char *)&lli->lli_vfs_inode - (char *)lli);
759 sema_init(&lli->lli_open_sem, 1);
760 init_MUTEX(&lli->lli_size_valid_sem);
761 lli->lli_maxbytes = LUSTRE_STRIPE_MAXBYTES;
763 return &lli->lli_vfs_inode;
766 static void ll_destroy_inode(struct inode *inode)
768 OBD_SLAB_FREE(ll_inode_cachep, ll_i2info(inode),
769 sizeof(struct ll_inode_info));
772 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
774 struct ll_inode_info *lli = foo;
776 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
777 SLAB_CTOR_CONSTRUCTOR)
778 inode_init_once(&lli->lli_vfs_inode);
781 int ll_init_inodecache(void)
783 ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
784 sizeof(struct ll_inode_info),
785 0, SLAB_HWCACHE_ALIGN,
787 if (ll_inode_cachep == NULL)
792 void ll_destroy_inodecache(void)
794 if (kmem_cache_destroy(ll_inode_cachep))
795 CERROR("ll_inode_cache: not all structures were freed\n");
800 /* exported operations */
801 struct super_operations ll_super_operations =
803 alloc_inode: ll_alloc_inode,
804 destroy_inode: ll_destroy_inode,
805 clear_inode: ll_clear_inode,
806 // delete_inode: ll_delete_inode,
807 put_super: ll_put_super,
809 umount_begin: ll_umount_begin
813 struct file_system_type lustre_lite_fs_type = {
814 .owner = THIS_MODULE,
815 .name = "lustre_lite",
817 .kill_sb = kill_anon_super,
820 static int __init init_lustre_lite(void)
823 printk(KERN_INFO "Lustre Lite Client File System; "
824 "info@clusterfs.com\n");
825 rc = ll_init_inodecache();
828 ll_file_data_slab = kmem_cache_create("ll_file_data",
829 sizeof(struct ll_file_data), 0,
830 SLAB_HWCACHE_ALIGN, NULL, NULL);
831 if (ll_file_data_slab == NULL) {
832 ll_destroy_inodecache();
836 proc_lustre_fs_root = proc_lustre_root ?
837 proc_mkdir("llite", proc_lustre_root) : NULL;
839 return register_filesystem(&lustre_lite_fs_type);
842 static void __exit exit_lustre_lite(void)
844 unregister_filesystem(&lustre_lite_fs_type);
845 ll_destroy_inodecache();
846 kmem_cache_destroy(ll_file_data_slab);
847 if (proc_lustre_fs_root) {
848 lprocfs_remove(proc_lustre_fs_root);
849 proc_lustre_fs_root = NULL;
853 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
854 MODULE_DESCRIPTION("Lustre Lite Client File System");
855 MODULE_LICENSE("GPL");
857 module_init(init_lustre_lite);
858 module_exit(exit_lustre_lite);