Commit 5f257fd8 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nathan Scott

[XFS] Move a couple of routines with knowledge of pagebuf targets, block devices,

and struct inodes down in with the rest of the Linux-specific code.

SGI Modid: 2.5.x-xfs:slinx:130824a
parent 1d132b53
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/pagemap.h>
#include <linux/major.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
...@@ -43,6 +45,10 @@ ...@@ -43,6 +45,10 @@
extern int xfs_init(void); extern int xfs_init(void);
extern void xfs_cleanup(void); extern void xfs_cleanup(void);
#ifndef EVMS_MAJOR
# define EVMS_MAJOR 117
#endif
/* For kernels which have the s_maxbytes field - set it */ /* For kernels which have the s_maxbytes field - set it */
#ifdef MAX_NON_LFS #ifdef MAX_NON_LFS
# define set_max_bytes(sb) ((sb)->s_maxbytes = XFS_MAX_FILE_OFFSET) # define set_max_bytes(sb) ((sb)->s_maxbytes = XFS_MAX_FILE_OFFSET)
...@@ -371,7 +377,7 @@ xfs_showargs( ...@@ -371,7 +377,7 @@ xfs_showargs(
return 0; return 0;
} }
void STATIC __inline__ void
xfs_set_inodeops( xfs_set_inodeops(
struct inode *inode) struct inode *inode)
{ {
...@@ -397,6 +403,134 @@ xfs_set_inodeops( ...@@ -397,6 +403,134 @@ xfs_set_inodeops(
} }
} }
STATIC __inline__ void
xfs_revalidate_inode(
xfs_mount_t *mp,
vnode_t *vp,
xfs_inode_t *ip)
{
struct inode *inode = LINVFS_GET_IP(vp);
inode->i_mode = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type);
inode->i_nlink = ip->i_d.di_nlink;
inode->i_uid = ip->i_d.di_uid;
inode->i_gid = ip->i_d.di_gid;
if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {
inode->i_rdev = NODEV;
} else {
xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
inode->i_rdev = XFS_DEV_TO_KDEVT(dev);
}
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_generation = ip->i_d.di_gen;
inode->i_size = ip->i_d.di_size;
inode->i_blocks =
XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
inode->i_atime = ip->i_d.di_atime.t_sec;
inode->i_mtime = ip->i_d.di_mtime.t_sec;
inode->i_ctime = ip->i_d.di_ctime.t_sec;
vp->v_flag &= ~VMODIFIED;
}
void
xfs_initialize_vnode(
bhv_desc_t *bdp,
vnode_t *vp,
bhv_desc_t *inode_bhv,
int unlock)
{
xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
struct inode *inode = LINVFS_GET_IP(vp);
if (vp->v_fbhv == NULL) {
vp->v_vfsp = bhvtovfs(bdp);
bhv_desc_init(&(ip->i_bhv_desc), ip, vp, &xfs_vnodeops);
bhv_insert_initial(VN_BHV_HEAD(vp), &(ip->i_bhv_desc));
}
vp->v_type = IFTOVT(ip->i_d.di_mode);
/* Have we been called during the new inode create process,
* in which case we are too early to fill in the linux inode.
*/
if (vp->v_type == VNON)
return;
xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
/* For new inodes we need to set the ops vectors,
* and unlock the inode.
*/
if (unlock && (inode->i_state & I_NEW)) {
xfs_set_inodeops(inode);
unlock_new_inode(inode);
}
}
int
xfs_blkdev_get(
const char *name,
struct block_device **bdevp)
{
struct nameidata nd;
int error;
error = path_lookup(name, LOOKUP_FOLLOW, &nd);
if (error) {
printk("XFS: Invalid device [%s], error=%d\n",
name, error);
return error;
}
/* I think we actually want bd_acquire here.. --hch */
*bdevp = bdget(kdev_t_to_nr(nd.dentry->d_inode->i_rdev));
if (*bdevp) {
error = blkdev_get(*bdevp, FMODE_READ|FMODE_WRITE, 0, BDEV_FS);
} else {
error = -ENOMEM;
}
path_release(&nd);
return -error;
}
void
xfs_blkdev_put(
struct block_device *bdev)
{
blkdev_put(bdev, BDEV_FS);
}
void
xfs_free_buftarg(
xfs_buftarg_t *btp)
{
pagebuf_delwri_flush(btp, PBDF_WAIT, NULL);
kfree(btp);
}
xfs_buftarg_t *
xfs_alloc_buftarg(
struct block_device *bdev)
{
xfs_buftarg_t *btp;
btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
btp->pbr_dev = bdev->bd_dev;
btp->pbr_bdev = bdev;
btp->pbr_mapping = bdev->bd_inode->i_mapping;
btp->pbr_blocksize = PAGE_CACHE_SIZE;
switch (MAJOR(btp->pbr_dev)) {
case MD_MAJOR:
case EVMS_MAJOR:
btp->pbr_flags = PBR_ALIGNED_ONLY;
break;
}
return btp;
}
STATIC kmem_cache_t * linvfs_inode_cachep; STATIC kmem_cache_t * linvfs_inode_cachep;
...@@ -517,6 +651,7 @@ linvfs_fill_super( ...@@ -517,6 +651,7 @@ linvfs_fill_super(
sb->s_dirt = 1; sb->s_dirt = 1;
sb->s_blocksize = statvfs.f_bsize; sb->s_blocksize = statvfs.f_bsize;
sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1; sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1;
set_posix_acl(sb);
VFS_ROOT(vfsp, &rootvp, error); VFS_ROOT(vfsp, &rootvp, error);
if (error) if (error)
...@@ -544,9 +679,8 @@ linvfs_fill_super( ...@@ -544,9 +679,8 @@ linvfs_fill_super(
goto fail_vnrele; goto fail_vnrele;
} }
} }
set_posix_acl(sb);
vn_trace_exit(rootvp, "linvfs_read_super", (inst_t *)__return_address); vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
kfree(args); kfree(args);
return 0; return 0;
...@@ -575,7 +709,7 @@ linvfs_fill_super( ...@@ -575,7 +709,7 @@ linvfs_fill_super(
* super block dirty so that sync_supers calls us and * super block dirty so that sync_supers calls us and
* forces the flush. * forces the flush.
*/ */
void STATIC void
linvfs_write_inode( linvfs_write_inode(
struct inode *inode, struct inode *inode,
int sync) int sync)
...@@ -584,9 +718,7 @@ linvfs_write_inode( ...@@ -584,9 +718,7 @@ linvfs_write_inode(
int error, flags = FLUSH_INODE; int error, flags = FLUSH_INODE;
if (vp) { if (vp) {
vn_trace_entry(vp, "linvfs_write_inode", vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
(inst_t *)__return_address);
if (sync) if (sync)
flags |= FLUSH_SYNC; flags |= FLUSH_SYNC;
VOP_IFLUSH(vp, flags, error); VOP_IFLUSH(vp, flags, error);
...@@ -595,7 +727,7 @@ linvfs_write_inode( ...@@ -595,7 +727,7 @@ linvfs_write_inode(
} }
} }
void STATIC void
linvfs_clear_inode( linvfs_clear_inode(
struct inode *inode) struct inode *inode)
{ {
...@@ -603,8 +735,7 @@ linvfs_clear_inode( ...@@ -603,8 +735,7 @@ linvfs_clear_inode(
if (vp) { if (vp) {
vn_rele(vp); vn_rele(vp);
vn_trace_entry(vp, "linvfs_clear_inode", vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
(inst_t *)__return_address);
/* /*
* Do all our cleanup, and remove this vnode. * Do all our cleanup, and remove this vnode.
*/ */
...@@ -613,7 +744,7 @@ linvfs_clear_inode( ...@@ -613,7 +744,7 @@ linvfs_clear_inode(
} }
} }
void STATIC void
linvfs_put_inode( linvfs_put_inode(
struct inode *ip) struct inode *ip)
{ {
...@@ -624,7 +755,7 @@ linvfs_put_inode( ...@@ -624,7 +755,7 @@ linvfs_put_inode(
VOP_RELEASE(vp, error); VOP_RELEASE(vp, error);
} }
void STATIC void
linvfs_put_super( linvfs_put_super(
struct super_block *sb) struct super_block *sb)
{ {
...@@ -634,14 +765,14 @@ linvfs_put_super( ...@@ -634,14 +765,14 @@ linvfs_put_super(
VFS_DOUNMOUNT(vfsp, 0, NULL, NULL, error); VFS_DOUNMOUNT(vfsp, 0, NULL, NULL, error);
if (error) { if (error) {
printk("XFS unmount got error %d\n", error); printk("XFS unmount got error %d\n", error);
printk("linvfs_put_super: vfsp/0x%p left dangling!\n", vfsp); printk("%s: vfsp/0x%p left dangling!\n", __FUNCTION__, vfsp);
return; return;
} }
vfs_deallocate(vfsp); vfs_deallocate(vfsp);
} }
void STATIC void
linvfs_write_super( linvfs_write_super(
struct super_block *sb) struct super_block *sb)
{ {
...@@ -655,7 +786,7 @@ linvfs_write_super( ...@@ -655,7 +786,7 @@ linvfs_write_super(
NULL, error); NULL, error);
} }
int STATIC int
linvfs_statfs( linvfs_statfs(
struct super_block *sb, struct super_block *sb,
struct statfs *statp) struct statfs *statp)
...@@ -664,11 +795,10 @@ linvfs_statfs( ...@@ -664,11 +795,10 @@ linvfs_statfs(
int error; int error;
VFS_STATVFS(vfsp, statp, NULL, error); VFS_STATVFS(vfsp, statp, NULL, error);
return error; return error;
} }
int STATIC int
linvfs_remount( linvfs_remount(
struct super_block *sb, struct super_block *sb,
int *flags, int *flags,
...@@ -716,7 +846,7 @@ linvfs_remount( ...@@ -716,7 +846,7 @@ linvfs_remount(
return error; return error;
} }
void STATIC void
linvfs_freeze_fs( linvfs_freeze_fs(
struct super_block *sb) struct super_block *sb)
{ {
...@@ -732,7 +862,7 @@ linvfs_freeze_fs( ...@@ -732,7 +862,7 @@ linvfs_freeze_fs(
VN_RELE(vp); VN_RELE(vp);
} }
void STATIC void
linvfs_unfreeze_fs( linvfs_unfreeze_fs(
struct super_block *sb) struct super_block *sb)
{ {
...@@ -746,7 +876,6 @@ linvfs_unfreeze_fs( ...@@ -746,7 +876,6 @@ linvfs_unfreeze_fs(
VN_RELE(vp); VN_RELE(vp);
} }
STATIC struct dentry * STATIC struct dentry *
linvfs_get_parent( linvfs_get_parent(
struct dentry *child) struct dentry *child)
......
...@@ -73,15 +73,20 @@ ...@@ -73,15 +73,20 @@
XFS_QUOTA_STRING XFS_VNTRACE_STRING \ XFS_QUOTA_STRING XFS_VNTRACE_STRING \
XFS_DBG_STRING /* DBG must be last */ XFS_DBG_STRING /* DBG must be last */
#define LINVFS_GET_VFS(s) \ #define LINVFS_GET_VFS(s) \
(vfs_t *)((s)->s_fs_info) (vfs_t *)((s)->s_fs_info)
#define LINVFS_SET_VFS(s, vfsp) \ #define LINVFS_SET_VFS(s, vfsp) \
((s)->s_fs_info = vfsp) ((s)->s_fs_info = vfsp)
struct pb_target;
struct block_device;
extern void xfs_initialize_vnode (bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
extern int xfs_blkdev_get (const char *, struct block_device **);
extern void xfs_blkdev_put (struct block_device *);
extern void extern struct pb_target *xfs_alloc_buftarg (struct block_device *);
xfs_set_inodeops( extern void xfs_free_buftarg (struct pb_target *);
struct inode *inode);
#endif /* __XFS_SUPER_H__ */ #endif /* __XFS_SUPER_H__ */
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
*/ */
#include <xfs.h> #include <xfs.h>
#include <linux/pagemap.h>
/* /*
* Initialize the inode hash table for the newly mounted file system. * Initialize the inode hash table for the newly mounted file system.
...@@ -110,36 +108,6 @@ xfs_chash_free(xfs_mount_t *mp) ...@@ -110,36 +108,6 @@ xfs_chash_free(xfs_mount_t *mp)
mp->m_chash = NULL; mp->m_chash = NULL;
} }
void
xfs_revalidate_inode(
xfs_mount_t *mp,
vnode_t *vp,
xfs_inode_t *ip)
{
struct inode *inode = LINVFS_GET_IP(vp);
inode->i_mode = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type);
inode->i_nlink = ip->i_d.di_nlink;
inode->i_uid = ip->i_d.di_uid;
inode->i_gid = ip->i_d.di_gid;
if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {
inode->i_rdev = NODEV;
} else {
xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
inode->i_rdev = XFS_DEV_TO_KDEVT(dev);
}
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_generation = ip->i_d.di_gen;
inode->i_size = ip->i_d.di_size;
inode->i_blocks =
XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
inode->i_atime = ip->i_d.di_atime.t_sec;
inode->i_mtime = ip->i_d.di_mtime.t_sec;
inode->i_ctime = ip->i_d.di_ctime.t_sec;
vp->v_flag &= ~VMODIFIED;
}
/* /*
* Look up an inode by number in the given file system. * Look up an inode by number in the given file system.
* The inode is looked up in the hash table for the file system * The inode is looked up in the hash table for the file system
......
...@@ -31,13 +31,6 @@ ...@@ -31,13 +31,6 @@
*/ */
#include <xfs.h> #include <xfs.h>
#include <linux/major.h>
#include <linux/namei.h>
#include <linux/pagemap.h>
#ifndef EVMS_MAJOR
#define EVMS_MAJOR 117
#endif
STATIC void xfs_mount_reset_sbqflags(xfs_mount_t *); STATIC void xfs_mount_reset_sbqflags(xfs_mount_t *);
STATIC void xfs_mount_log_sbunit(xfs_mount_t *, __int64_t); STATIC void xfs_mount_log_sbunit(xfs_mount_t *, __int64_t);
...@@ -1731,68 +1724,3 @@ xfs_check_frozen( ...@@ -1731,68 +1724,3 @@ xfs_check_frozen(
if (level == XFS_FREEZE_TRANS) if (level == XFS_FREEZE_TRANS)
atomic_inc(&mp->m_active_trans); atomic_inc(&mp->m_active_trans);
} }
int
xfs_blkdev_get(
const char *name,
struct block_device **bdevp)
{
struct nameidata nd;
int error = 0;
error = path_lookup(name, LOOKUP_FOLLOW, &nd);
if (error) {
printk("XFS: Invalid device [%s], error=%d\n",
name, error);
return error;
}
/* I think we actually want bd_acquire here.. --hch */
*bdevp = bdget(kdev_t_to_nr(nd.dentry->d_inode->i_rdev));
if (*bdevp) {
error = blkdev_get(*bdevp, FMODE_READ|FMODE_WRITE, 0, BDEV_FS);
} else {
error = -ENOMEM;
}
path_release(&nd);
return -error;
}
void
xfs_blkdev_put(
struct block_device *bdev)
{
blkdev_put(bdev, BDEV_FS);
}
void
xfs_free_buftarg(
xfs_buftarg_t *btp)
{
pagebuf_delwri_flush(btp, PBDF_WAIT, NULL);
kfree(btp);
}
xfs_buftarg_t *
xfs_alloc_buftarg(
struct block_device *bdev)
{
xfs_buftarg_t *btp;
btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
btp->pbr_dev = bdev->bd_dev;
btp->pbr_bdev = bdev;
btp->pbr_mapping = bdev->bd_inode->i_mapping;
btp->pbr_blocksize = PAGE_CACHE_SIZE;
switch (MAJOR(btp->pbr_dev)) {
case MD_MAJOR:
case EVMS_MAJOR:
btp->pbr_flags = PBR_ALIGNED_ONLY;
break;
}
return btp;
}
...@@ -1567,40 +1567,6 @@ xfs_syncsub( ...@@ -1567,40 +1567,6 @@ xfs_syncsub(
return XFS_ERROR(last_error); return XFS_ERROR(last_error);
} }
STATIC void
xfs_initialize_vnode(
bhv_desc_t *bdp,
vnode_t *vp,
bhv_desc_t *inode_bhv,
int unlock)
{
xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
struct inode *inode = LINVFS_GET_IP(vp);
if (vp->v_fbhv == NULL) {
vp->v_vfsp = bhvtovfs(bdp);
bhv_desc_init(&(ip->i_bhv_desc), ip, vp, &xfs_vnodeops);
bhv_insert_initial(VN_BHV_HEAD(vp), &(ip->i_bhv_desc));
}
vp->v_type = IFTOVT(ip->i_d.di_mode);
/* Have we been called during the new inode create process,
* in which case we are too early to fill in the linux inode.
*/
if (vp->v_type == VNON)
return;
xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
/* For new inodes we need to set the ops vectors,
* and unlock the inode.
*/
if (unlock && (inode->i_state & I_NEW)) {
xfs_set_inodeops(inode);
unlock_new_inode(inode);
}
}
/* /*
* xfs_vget - called by DMAPI to get vnode from file handle * xfs_vget - called by DMAPI to get vnode from file handle
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment