1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define DEBUG_SUBSYSTEM S_SM
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/string.h>
28 #include <linux/slab.h>
29 #include <linux/stat.h>
30 #include <linux/unistd.h>
31 #include <linux/smp_lock.h>
32 #include <linux/obd_class.h>
33 #include <linux/obd_support.h>
34 #include <linux/lustre_lib.h>
35 #include <linux/lustre_idl.h>
36 #include <linux/lustre_fsfilt.h>
37 #include <linux/lustre_smfs.h>
38 #include <linux/lustre_snap.h>
39 #include <linux/security.h>
40 #include "smfs_internal.h"
42 //#define NAME_ALLOC_LEN(len) ((len+16) & ~15)
44 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
45 static int smfs_create(struct inode *dir, struct dentry *dentry,
48 static int smfs_create(struct inode *dir, struct dentry *dentry,
49 int mode, struct nameidata *nd)
52 struct inode *inode = NULL;
53 struct inode *parent = I2CI(dentry->d_parent->d_inode);
54 struct inode *cache_dir = I2CI(dir);
55 struct dentry *cache_dentry = NULL;
56 struct dentry *cache_parent = NULL;
58 struct hook_msg msg = {
65 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s (%p),dir=%lu/%u\n",
66 dentry->d_name.len, dentry->d_name.name, dentry,
67 dir->i_ino, dir->i_generation);
70 LASSERT(cache_dir->i_op->create);
72 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
73 cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry);
74 if (!cache_dentry || !cache_parent) {
79 handle = smfs_trans_start(dir, FSFILT_OP_CREATE, NULL);
85 SMFS_PRE_HOOK(dir, HOOK_CREATE, &msg);
87 pre_smfs_inode(dir, cache_dir);
89 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
90 rc = cache_dir->i_op->create(cache_dir, cache_dentry, mode);
92 rc = cache_dir->i_op->create(cache_dir, cache_dentry, mode, nd);
95 inode = smfs_get_inode(dir->i_sb, cache_dentry->d_inode,
98 d_instantiate(dentry, inode);
104 SMFS_POST_HOOK(dir, HOOK_CREATE, &msg, rc);
106 post_smfs_inode(dir, cache_dir);
107 smfs_trans_commit(dir, handle, 0);
110 post_smfs_dentry(cache_dentry);
111 post_smfs_dentry(cache_parent);
115 static struct dentry * iopen_connect_dentry(struct dentry * dentry,
116 struct inode *inode, int rehash)
118 struct dentry *tmp, *goal = NULL;
119 struct list_head *lp;
121 /* verify this dentry is really new */
122 LASSERT(dentry->d_inode == NULL);
123 LASSERT(list_empty(&dentry->d_alias)); /* d_instantiate */
125 LASSERT(d_unhashed(dentry)); /* d_rehash */
126 LASSERT(list_empty(&dentry->d_subdirs));
128 spin_lock(&dcache_lock);
132 /* preferrably return a connected dentry */
133 list_for_each(lp, &inode->i_dentry) {
134 tmp = list_entry(lp, struct dentry, d_alias);
135 if (tmp->d_flags & DCACHE_DISCONNECTED) {
136 LASSERT(tmp->d_alias.next == &inode->i_dentry);
137 LASSERT(tmp->d_alias.prev == &inode->i_dentry);
147 /* Move the goal to the de hash queue */
148 goal->d_flags &= ~ DCACHE_DISCONNECTED;
149 security_d_instantiate(goal, inode);
151 __d_move(goal, dentry);
152 spin_unlock(&dcache_lock);
157 /* d_add(), but don't drop dcache_lock before adding dentry to inode */
159 list_add(&dentry->d_alias, &inode->i_dentry); /* d_instantiate */
160 dentry->d_inode = inode;
164 spin_unlock(&dcache_lock);
170 static int smfs_do_lookup (struct inode * dir,
171 struct dentry * dentry,
172 struct nameidata *nd,
173 struct inode **inode)
175 struct inode *cache_dir = I2CI(dir);
176 struct inode *parent = I2CI(dentry->d_parent->d_inode);
177 struct dentry *cache_dentry = NULL;
178 struct dentry *cache_parent = NULL;
179 struct dentry *rdentry = NULL, *tmp = NULL;
181 struct hook_msg msg = {
187 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s (%p),dir=%lu/%u\n",
188 dentry->d_name.len, dentry->d_name.name, dentry,
189 dir->i_ino, dir->i_generation);
194 LASSERT(cache_dir->i_op->lookup);
196 /* preparing artificial backing fs dentries. */
197 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
198 cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry);
199 if (!cache_dentry || !cache_parent) {
204 SMFS_PRE_HOOK(dir, HOOK_LOOKUP, &msg);
206 /* perform lookup in backing fs. */
207 rdentry = cache_dir->i_op->lookup(cache_dir, cache_dentry, nd);
209 if (IS_ERR(rdentry)) {
210 rc = PTR_ERR(rdentry);
219 SMFS_POST_HOOK(dir, HOOK_LOOKUP, &msg, rc);
222 //copy fields if DCACHE_CROSS_REF
223 smfs_update_dentry(dentry, tmp);
226 *inode = smfs_get_inode(dir->i_sb, tmp->d_inode,
230 else if (!tmp->d_inode->i_nlink) {
231 struct inode * ind = tmp->d_inode;
233 CDEBUG(D_ERROR, "inode #%lu (%*s) nlink is %i/%i\n",
234 ind->i_ino, tmp->d_name.len,
235 tmp->d_name.name, ind->i_nlink,
237 CDEBUG(D_ERROR, "parent #%lu (%*s) nlink is %i\n",
238 dir->i_ino, tmp->d_parent->d_name.len,
239 tmp->d_parent->d_name.name,
241 CDEBUG(D_ERROR, "i_mode %o, rc = %d\n",
244 if (is_bad_inode(ind))
245 CDEBUG(D_ERROR, "bad inode returned %lu/%u\n",
246 ind->i_ino, ind->i_generation);
256 post_smfs_dentry(cache_dentry);
257 post_smfs_dentry(cache_parent);
262 static struct dentry * smfs_iopen_lookup(struct inode * dir,
263 struct dentry *dentry,
264 struct nameidata *nd)
266 struct dentry * alternate = NULL;
267 struct inode *inode = NULL;
271 rc = smfs_do_lookup(dir, dentry, nd, &inode);
276 /* preferrably return a connected dentry */
277 spin_lock(&dcache_lock);
278 list_for_each_entry(alternate, &inode->i_dentry, d_alias) {
279 LASSERT(!(alternate->d_flags & DCACHE_DISCONNECTED));
282 list_for_each_entry(alternate, &inode->i_dentry, d_alias) {
283 dget_locked(alternate);
284 spin_lock(&alternate->d_lock);
285 alternate->d_flags |= DCACHE_REFERENCED;
286 spin_unlock(&alternate->d_lock);
288 spin_unlock(&dcache_lock);
292 dentry->d_flags |= DCACHE_DISCONNECTED;
294 /* d_add(), but don't drop dcache_lock before adding dentry to inode */
295 list_add(&dentry->d_alias, &inode->i_dentry); /* d_instantiate */
296 dentry->d_inode = inode;
298 __d_rehash(dentry); /* d_rehash */
299 spin_unlock(&dcache_lock);
304 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
305 static struct dentry *smfs_lookup(struct inode *dir, struct dentry *dentry)
307 static struct dentry *smfs_lookup(struct inode *dir, struct dentry *dentry,
308 struct nameidata *nd)
311 struct dentry * rdentry = NULL;
312 struct inode * inode = NULL;
317 rc = smfs_do_lookup(dir, dentry, nd, &inode);
321 //lmv stuff. Special dentry that has no inode.
322 if (dentry->d_flags & DCACHE_CROSS_REF) {
326 //TODO: should flags be checked and copied before?
327 rdentry = iopen_connect_dentry(dentry, inode, 1);
333 static int smfs_lookup_raw(struct inode *dir, const char *name,
334 int len, ino_t *data)
336 struct inode *cache_dir = I2CI(dir);
342 if (cache_dir->i_op->lookup_raw) {
343 rc = cache_dir->i_op->lookup_raw(cache_dir, name, len, data);
345 CWARN("do not have raw lookup ops in bottom fs\n");
352 static int smfs_link(struct dentry *old_dentry,
353 struct inode *dir, struct dentry *dentry)
355 struct inode *parent = I2CI(dentry->d_parent->d_inode);
356 struct inode *cache_dir = I2CI(dir);
357 struct inode *old_inode = old_dentry->d_inode;
358 struct inode *cache_old_inode = I2CI(old_inode);
359 struct dentry *cache_old_dentry = NULL;
360 struct dentry *cache_dentry = NULL;
361 struct dentry *cache_parent = NULL;
364 struct hook_link_msg msg = {
365 .dentry = old_dentry,
374 if (!cache_old_inode)
377 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
378 cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry);
379 cache_old_dentry = pre_smfs_dentry(NULL, cache_old_inode, old_dentry);
380 if (!cache_old_dentry || !cache_dentry || !cache_parent) {
385 handle = smfs_trans_start(dir, FSFILT_OP_LINK, NULL);
386 if (IS_ERR(handle)) {
391 pre_smfs_inode(dir, cache_dir);
392 pre_smfs_inode(old_inode, cache_old_inode);
395 SMFS_PRE_HOOK(dir, HOOK_LINK, &msg);
397 rc = cache_dir->i_op->link(cache_old_dentry, cache_dir, cache_dentry);
399 atomic_inc(&old_inode->i_count);
400 old_inode->i_nlink++;
401 dput(iopen_connect_dentry(dentry, old_inode, 0));
404 SMFS_POST_HOOK(dir, HOOK_LINK, &msg, rc);
406 post_smfs_inode(old_inode, cache_old_inode);
407 post_smfs_inode(dir, cache_dir);
409 smfs_trans_commit(dir, handle, 0);
413 post_smfs_dentry(cache_dentry);
414 post_smfs_dentry(cache_parent);
415 post_smfs_dentry(cache_old_dentry);
420 static int smfs_unlink(struct inode * dir, struct dentry *dentry)
422 struct inode *cache_dir = I2CI(dir);
423 struct inode *cache_inode = I2CI(dentry->d_inode);
424 struct inode *parent = I2CI(dentry->d_parent->d_inode);
425 struct dentry *cache_dentry = NULL;
426 struct dentry *cache_parent = NULL;
430 struct hook_unlink_msg msg = {
432 .mode = dentry->d_inode->i_mode
438 LASSERT(cache_inode);
439 LASSERT(cache_dir->i_op->unlink);
442 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s (%p),dir=%lu/%u\n",
443 dentry->d_name.len, dentry->d_name.name, dentry,
444 dir->i_ino, dir->i_generation);
446 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
447 cache_dentry = pre_smfs_dentry(cache_parent, cache_inode, dentry);
448 if (!cache_dentry || !cache_parent) {
453 handle = smfs_trans_start(dir, FSFILT_OP_UNLINK, NULL);
454 if (IS_ERR(handle)) {
459 pre_smfs_inode(dir, cache_dir);
460 pre_smfs_inode(dentry->d_inode, cache_inode);
462 SMFS_PRE_HOOK(dir, HOOK_UNLINK, &msg);
464 rc = cache_dir->i_op->unlink(cache_dir, cache_dentry);
466 /* We don't d_delete() NFS sillyrenamed files--they still exist. */
467 if (!rc && !(cache_dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
468 d_delete(cache_dentry);
471 SMFS_POST_HOOK(dir, HOOK_UNLINK, &msg, rc);
473 post_smfs_inode(dentry->d_inode, cache_inode);
474 dentry->d_inode->i_nlink--;
475 post_smfs_inode(dir, cache_dir);
478 smfs_trans_commit(dir, handle, 0);
480 post_smfs_dentry(cache_dentry);
481 post_smfs_dentry(cache_parent);
485 static int smfs_symlink(struct inode *dir, struct dentry *dentry,
488 struct inode *cache_dir = I2CI(dir);
489 struct inode *inode = NULL;
490 struct inode *parent = I2CI(dentry->d_parent->d_inode);
491 struct dentry *cache_dentry = NULL;
492 struct dentry *cache_parent = NULL;
495 struct hook_symlink_msg msg = {
497 .tgt_len = strlen(symname) + 1,
498 .symname = (char*)symname
504 LASSERT(cache_dir->i_op->symlink);
507 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
508 cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry);
509 if (!cache_parent || !cache_dentry) {
514 handle = smfs_trans_start(dir, FSFILT_OP_SYMLINK, NULL);
515 if (IS_ERR(handle)) {
520 pre_smfs_inode(dir, cache_dir);
522 SMFS_PRE_HOOK(dir, HOOK_SYMLINK, &msg);
524 rc = cache_dir->i_op->symlink(cache_dir, cache_dentry, symname);
526 inode = smfs_get_inode(dir->i_sb, cache_dentry->d_inode,
529 d_instantiate(dentry, inode);
535 SMFS_POST_HOOK(dir, HOOK_SYMLINK, &msg, rc);
537 post_smfs_inode(dir, cache_dir);
538 smfs_trans_commit(dir, handle, 0);
541 post_smfs_dentry(cache_dentry);
542 post_smfs_dentry(cache_parent);
546 static int smfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
548 struct inode *cache_dir = I2CI(dir);
549 struct inode *parent = I2CI(dentry->d_parent->d_inode);
550 struct inode *inode = NULL;
551 struct dentry *cache_dentry = NULL;
552 struct dentry *cache_parent = NULL;
555 struct hook_msg msg = {
564 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s (%p),dir=%lu/%u\n",
565 dentry->d_name.len, dentry->d_name.name, dentry,
566 dir->i_ino, dir->i_generation);
568 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
569 cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry);
570 if (!cache_parent || !cache_dentry) {
575 handle = smfs_trans_start(dir, FSFILT_OP_MKDIR, NULL);
576 if (IS_ERR(handle)) {
581 pre_smfs_inode(dir, cache_dir);
582 SMFS_PRE_HOOK(dir, HOOK_MKDIR, &msg);
584 rc = cache_dir->i_op->mkdir(cache_dir, cache_dentry, mode);
586 inode = smfs_get_inode(dir->i_sb, cache_dentry->d_inode,
590 d_instantiate(dentry, inode);
596 SMFS_POST_HOOK(dir, HOOK_MKDIR, &msg, rc);
597 post_smfs_inode(dir, cache_dir);
598 smfs_trans_commit(dir, handle, 0);
601 post_smfs_dentry(cache_dentry);
602 post_smfs_dentry(cache_parent);
606 static int smfs_rmdir(struct inode *dir, struct dentry *dentry)
608 struct inode *cache_dir = I2CI(dir);
609 struct inode *cache_inode = I2CI(dentry->d_inode);
610 struct inode *parent = I2CI(dentry->d_parent->d_inode);
611 struct dentry *cache_dentry = NULL;
612 struct dentry *cache_parent = NULL;
613 struct inode * inode = dentry->d_inode;
616 struct hook_unlink_msg msg = {
623 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s (%p),dir=%lu/%u\n",
624 dentry->d_name.len, dentry->d_name.name, dentry,
625 dir->i_ino, dir->i_generation);
628 LASSERT(cache_dir->i_op->rmdir);
631 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
632 cache_dentry = pre_smfs_dentry(cache_parent, cache_inode, dentry);
633 if (!cache_parent || !cache_dentry) {
638 handle = smfs_trans_start(dir, FSFILT_OP_RMDIR, NULL);
639 if (IS_ERR(handle) ) {
644 dentry_unhash(cache_dentry);
646 pre_smfs_inode(dir, cache_dir);
647 pre_smfs_inode(inode, cache_inode);
649 SMFS_PRE_HOOK(dir, HOOK_RMDIR, &msg);
651 rc = cache_dir->i_op->rmdir(cache_dir, cache_dentry);
653 SMFS_POST_HOOK(dir, HOOK_RMDIR, &msg, rc);
655 if (inode->i_nlink != 2)
656 CWARN("Directory #%lu under rmdir has %i nlinks\n",
657 inode->i_ino, inode->i_nlink);
660 post_smfs_inode(dir, cache_dir);
661 post_smfs_inode(inode, cache_inode);
662 //like vfs_rmdir is doing with inode
663 cache_inode->i_flags |= S_DEAD;
664 d_delete(cache_dentry);
666 smfs_trans_commit(dir, handle, 0);
670 post_smfs_dentry(cache_dentry);
671 post_smfs_dentry(cache_parent);
675 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
676 static int smfs_mknod(struct inode *dir, struct dentry *dentry,
679 static int smfs_mknod(struct inode *dir, struct dentry *dentry,
680 int mode, dev_t rdev)
683 struct inode *cache_dir = I2CI(dir);
684 struct inode *inode = NULL;
685 struct inode *parent = I2CI(dentry->d_parent->d_inode);
686 struct dentry *cache_dentry = NULL;
687 struct dentry *cache_parent = NULL;
690 struct hook_msg msg = {
698 LASSERT(cache_dir->i_op->mknod);
700 cache_parent = pre_smfs_dentry(NULL, parent, dentry->d_parent);
701 cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry);
702 if (!cache_parent || !cache_dentry) {
707 handle = smfs_trans_start(dir, FSFILT_OP_MKNOD, NULL);
708 if (IS_ERR(handle)) {
713 pre_smfs_inode(dir, cache_dir);
715 SMFS_PRE_HOOK(dir, HOOK_MKNOD, &msg);
717 rc = cache_dir->i_op->mknod(cache_dir, cache_dentry, mode, rdev);
719 inode = smfs_get_inode(dir->i_sb, cache_dentry->d_inode,
722 //smsf_update_dentry(dentry, cache_dentry);
723 d_instantiate(dentry, inode);
729 SMFS_POST_HOOK(dir, HOOK_MKNOD, &msg, rc);
731 post_smfs_inode(dir, cache_dir);
733 smfs_trans_commit(dir, handle, 0);
736 post_smfs_dentry(cache_dentry);
737 post_smfs_dentry(cache_parent);
741 static int smfs_rename(struct inode *old_dir, struct dentry *old_dentry,
742 struct inode *new_dir,struct dentry *new_dentry)
744 struct inode *cache_old_dir = I2CI(old_dir);
745 struct inode *cache_new_dir = I2CI(new_dir);
746 struct inode *new_inode = new_dentry->d_inode;
747 struct inode *cache_old_inode = I2CI(old_dentry->d_inode);
748 struct inode *old_parent = I2CI(old_dentry->d_parent->d_inode);
749 struct inode *new_parent = I2CI(new_dentry->d_parent->d_inode);
750 struct inode *cache_new_inode = NULL;
751 struct dentry *cache_old_dentry = NULL;
752 struct dentry *cache_new_dentry = NULL;
753 struct dentry *cache_new_parent = NULL;
754 struct dentry *cache_old_parent = NULL;
757 struct hook_rename_msg msg = {
758 .dentry = old_dentry,
761 .new_dentry = new_dentry,
766 if (!cache_old_dir || !cache_new_dir || !cache_old_inode)
770 cache_new_inode = I2CI(new_inode);
771 if (!cache_new_inode)
775 cache_old_parent = pre_smfs_dentry(NULL, old_parent, old_dentry->d_parent);
776 cache_old_dentry = pre_smfs_dentry(cache_old_parent, cache_old_inode,
778 if (!cache_old_parent || !cache_old_dentry) {
783 cache_new_parent = pre_smfs_dentry(NULL, new_parent, new_dentry->d_parent);
784 cache_new_dentry = pre_smfs_dentry(cache_new_parent, cache_new_inode,
786 if (!cache_new_parent || !cache_new_dentry) {
791 handle = smfs_trans_start(old_dir, FSFILT_OP_RENAME, NULL);
792 if (IS_ERR(handle)) {
797 pre_smfs_inode(old_dir, cache_old_dir);
798 pre_smfs_inode(new_dir, cache_new_dir);
799 pre_smfs_inode(old_dentry->d_inode, cache_old_inode);
801 pre_smfs_inode(new_inode, cache_new_inode);
803 SMFS_PRE_HOOK(old_dir, HOOK_RENAME, &msg);
805 rc = cache_old_dir->i_op->rename(cache_old_dir, cache_old_dentry,
806 cache_new_dir, cache_new_dentry);
808 SMFS_POST_HOOK(old_dir, HOOK_RENAME, &msg, rc);
810 post_smfs_inode(old_dir, cache_old_dir);
811 post_smfs_inode(new_dir, cache_new_dir);
812 post_smfs_inode(old_dentry->d_inode, cache_old_inode);
814 post_smfs_inode(new_inode, cache_new_inode);
815 new_inode->i_nlink--;
817 //directory is renamed
818 if (S_ISDIR(old_dentry->d_inode->i_mode)) {
821 new_inode->i_nlink--;
827 smfs_trans_commit(old_dir, handle, 0);
830 post_smfs_dentry(cache_old_dentry);
831 post_smfs_dentry(cache_old_parent);
832 post_smfs_dentry(cache_new_dentry);
833 post_smfs_dentry(cache_new_parent);
837 struct inode_operations smfs_dir_iops = {
838 .create = smfs_create,
839 .lookup = smfs_lookup,
841 .lookup_raw = smfs_lookup_raw,
844 .unlink = smfs_unlink,
845 .symlink = smfs_symlink,
849 .rename = smfs_rename,
850 .setxattr = smfs_setxattr,
851 .getxattr = smfs_getxattr,
852 .listxattr = smfs_listxattr,
853 .removexattr = smfs_removexattr,
854 .permission = smfs_permission,
857 struct inode_operations smfs_iopen_iops = {
858 .lookup = smfs_iopen_lookup,
861 static ssize_t smfs_read_dir(struct file *filp, char *buf,
862 size_t size, loff_t *ppos)
864 struct dentry *dentry = filp->f_dentry;
865 struct inode *cache_inode = NULL;
866 struct smfs_file_info *sfi = NULL;
868 loff_t *cache_ppos = NULL;
873 cache_inode = I2CI(dentry->d_inode);
875 if (!cache_inode || !cache_inode->i_fop->read)
879 if (sfi->magic != SMFS_FILE_MAGIC)
882 if (ppos != &(filp->f_pos))
883 cache_ppos = &tmp_ppos;
885 cache_ppos = &sfi->c_file->f_pos;
889 rc = cache_inode->i_fop->read(sfi->c_file, buf, size, cache_ppos);
895 duplicate_file(filp, sfi->c_file);
900 static int smfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
902 struct dentry *dentry = filp->f_dentry;
903 struct inode *cache_inode = NULL;
904 struct smfs_file_info *sfi = NULL;
909 cache_inode = I2CI(dentry->d_inode);
910 if (!cache_inode || !cache_inode->i_fop->readdir)
914 if (sfi->magic != SMFS_FILE_MAGIC) BUG();
916 rc = cache_inode->i_fop->readdir(sfi->c_file, dirent, filldir);
918 duplicate_file(filp, sfi->c_file);
923 struct file_operations smfs_dir_fops = {
924 .read = smfs_read_dir,
925 .readdir = smfs_readdir, /* BKL held */
926 .ioctl = smfs_ioctl, /* BKL held */
927 .fsync = smfs_fsync, /* BKL held */
929 .release = smfs_release,
932 struct file_operations smfs_iopen_fops = {
933 .read = smfs_read_dir,