#include "afs/sysincludes.h"
#include "afsincludes.h"
#include "afs/afs_stats.h"
-#include <linux/smp_lock.h>
#include "osi_compat.h"
/* Forward declarations */
static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp);
static int afs_root(struct super_block *afsp);
-struct super_block *afs_read_super(struct super_block *sb, void *data, int silent);
int afs_fill_super(struct super_block *sb, void *data, int silent);
-/* afs_file_system
- * VFS entry for Linux - installed in init_module
- * Linux mounts file systems by:
- * 1) register_filesystem(&afs_file_system) - done in init_module
- * 2) Mount call comes to us via do_mount -> read_super -> afs_read_super.
- * We are expected to setup the super_block. See afs_read_super.
- */
-
-/* afs_read_super
- * read the "super block" for AFS - roughly eguivalent to struct vfs.
- * dev, covered, s_rd_only, s_dirt, and s_type will be set by read_super.
+/*
+ * afs_mount (2.6.37+) and afs_get_sb (2.6.36-) are the entry
+ * points from the vfs when mounting afs. The super block
+ * structure is setup in the afs_fill_super callback function.
*/
-#ifdef GET_SB_HAS_STRUCT_VFSMOUNT
+
+#if defined(STRUCT_FILE_SYSTEM_TYPE_HAS_MOUNT)
+static struct dentry *
+afs_mount(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data) {
+ return mount_nodev(fs_type, flags, data, afs_fill_super);
+}
+#elif defined(GET_SB_HAS_STRUCT_VFSMOUNT)
static int
afs_get_sb(struct file_system_type *fs_type, int flags,
const char *dev_name, void *data, struct vfsmount *mnt) {
return get_sb_nodev(fs_type, flags, data, afs_fill_super, mnt);
}
#else
-static struct superblock *
+static struct super_block *
afs_get_sb(struct file_system_type *fs_type, int flags,
const char *dev_name, void *data) {
return get_sb_nodev(fs_type, flags, data, afs_fill_super);
struct file_system_type afs_fs_type = {
.owner = THIS_MODULE,
.name = "afs",
+#if defined(STRUCT_FILE_SYSTEM_TYPE_HAS_MOUNT)
+ .mount = afs_mount,
+#else
.get_sb = afs_get_sb,
+#endif
.kill_sb = kill_anon_super,
.fs_flags = FS_BINARY_MOUNTDATA,
};
sb->s_blocksize_bits = 10;
sb->s_magic = AFS_VFSMAGIC;
sb->s_op = &afs_sops; /* Super block (vfs) ops */
+
+#if defined(STRUCT_SUPER_BLOCK_HAS_S_D_OP)
+ sb->s_d_op = &afs_dentry_operations;
+#endif
+
/* used for inodes backing_dev_info field, also */
afs_backing_dev_info = osi_Alloc(sizeof(struct backing_dev_info));
-#if defined(HAVE_BDI_INIT)
+#if defined(HAVE_LINUX_BDI_INIT)
bdi_init(afs_backing_dev_info);
#endif
+#if defined(STRUCT_BACKING_DEV_INFO_HAS_NAME)
afs_backing_dev_info->name = "openafs";
+#endif
afs_backing_dev_info->ra_pages = 32;
#if defined (STRUCT_SUPER_BLOCK_HAS_S_BDI)
sb->s_bdi = afs_backing_dev_info;
static int
afs_root(struct super_block *afsp)
{
- register afs_int32 code = 0;
+ afs_int32 code = 0;
struct vrequest treq;
- register struct vcache *tvp = 0;
+ struct vcache *tvp = 0;
AFS_STATCNT(afs_root);
if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
/* setup super_block and mount point inode. */
afs_globalVp = tvp;
afsp->s_root = d_alloc_root(ip);
+#if !defined(STRUCT_SUPER_BLOCK_HAS_S_D_OP)
afsp->s_root->d_op = &afs_dentry_operations;
+#endif
} else
code = ENOENT;
}
VATTR_NULL(&vattr);
iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */
- lock_kernel();
AFS_GLOCK();
code = afs_setattr(VTOAFS(ip), &vattr, credp);
if (!code) {
vattr2inode(ip, &vattr);
}
AFS_GUNLOCK();
- unlock_kernel();
crfree(credp);
return -code;
}
-#if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
static afs_kmem_cache_t *afs_inode_cachep;
static struct inode *
}
#endif
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_EVICT_INODE)
+static void
+afs_evict_inode(struct inode *ip)
+{
+ struct vcache *vcp = VTOAFS(ip);
+
+ if (vcp->vlruq.prev || vcp->vlruq.next)
+ osi_Panic("inode freed while on LRU");
+ if (vcp->hnext)
+ osi_Panic("inode freed while still hashed");
+
+ truncate_inode_pages(&ip->i_data, 0);
+ end_writeback(ip);
+
+#if !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
+ afs_osi_Free(ip->u.generic_ip, sizeof(struct vcache));
+#endif
+}
+#else
static void
afs_clear_inode(struct inode *ip)
{
if (vcp->hnext)
osi_Panic("inode freed while still hashed");
-#if !defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+#if !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
afs_osi_Free(ip->u.generic_ip, sizeof(struct vcache));
#endif
}
+#endif
/* afs_put_super
* Called from unmount to release super_block. */
mntput(afs_cacheMnt);
osi_linux_verify_alloced_memory();
-#if defined(HAVE_BDI_INIT)
+#if defined(HAVE_LINUX_BDI_INIT)
bdi_destroy(afs_backing_dev_info);
#endif
osi_Free(afs_backing_dev_info, sizeof(struct backing_dev_info));
}
struct super_operations afs_sops = {
-#if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE)
.alloc_inode = afs_alloc_inode,
.destroy_inode = afs_destroy_inode,
#endif
+#if defined(STRUCT_SUPER_OPERATIONS_HAS_EVICT_INODE)
+ .evict_inode = afs_evict_inode,
+#else
.clear_inode = afs_clear_inode,
+#endif
.put_super = afs_put_super,
.statfs = afs_statfs,
};
struct vcache *tvc, *nvc;
extern struct vcache *afs_vhashT[VCSIZE];
+ retry:
for (i = 0; i < VCSIZE; i++) {
for (tvc = afs_vhashT[i]; tvc; ) {
int slept;
nvc = tvc->hnext;
- if (afs_FlushVCache(tvc, &slept)) /* slept always 0 for linux? */
+ if (afs_FlushVCache(tvc, &slept))
printf("Failed to invalidate all pages on inode 0x%p\n", tvc);
+ if (slept) {
+ goto retry;
+ }
tvc = nvc;
}
}