Commit 5301b18c authored by Nathan Scott's avatar Nathan Scott

[XFS] Seperate the NFS reference cache code out from xfs_rw.c to simplify...

[XFS] Seperate the NFS reference cache code out from xfs_rw.c to simplify management of different kernel versions.

SGI Modid: 2.5.x-xfs:slinx:162241a
parent e3f77734
......@@ -51,6 +51,7 @@
#include "xfs_fsops.h"
#include "xfs_itable.h"
#include "xfs_rw.h"
#include "xfs_refcache.h"
#include "xfs_trans_space.h"
#include "xfs_rtalloc.h"
#include "xfs_dir2.h"
......@@ -593,6 +594,9 @@ xfs_fs_freeze(
/* Stop new writers */
xfs_start_freeze(mp, XFS_FREEZE_WRITE);
/* Flush the refcache */
xfs_refcache_purge_mp(mp);
/* Flush delalloc and delwri data */
VFS_SYNC(vfsp, SYNC_DELWRI|SYNC_WAIT, NULL, error);
......
......@@ -271,7 +271,10 @@ typedef struct xfs_inode {
sema_t i_flock; /* inode flush lock */
atomic_t i_pincount; /* inode pin count */
wait_queue_head_t i_ipin_wait; /* inode pinning wait queue */
#ifdef HAVE_REFCACHE
struct xfs_inode **i_refcache; /* ptr to entry in ref cache */
struct xfs_inode *i_release; /* inode to unref */
#endif
/* I/O state */
xfs_iocore_t i_iocore; /* I/O core */
......
/*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/
#ifndef __XFS_REFCACHE_H__
#define __XFS_REFCACHE_H__
#ifdef HAVE_REFCACHE
/*
* Maximum size (in inodes) for the NFS reference cache
*/
#define XFS_REFCACHE_SIZE_MAX 512
struct xfs_inode;
struct xfs_mount;
extern void xfs_refcache_insert(struct xfs_inode *);
extern void xfs_refcache_purge_ip(struct xfs_inode *);
extern void xfs_refcache_purge_mp(struct xfs_mount *);
extern void xfs_refcache_purge_some(struct xfs_mount *);
extern void xfs_refcache_resize(int);
extern void xfs_refcache_destroy(void);
extern void xfs_refcache_iunlock(struct xfs_inode *, uint);
#else
#define xfs_refcache_insert(ip) do { } while (0)
#define xfs_refcache_purge_ip(ip) do { } while (0)
#define xfs_refcache_purge_mp(mp) do { } while (0)
#define xfs_refcache_purge_some(mp) do { } while (0)
#define xfs_refcache_resize(size) do { } while (0)
#define xfs_refcache_destroy() do { } while (0)
#define xfs_refcache_iunlock(ip, flags) xfs_iunlock(ip, flags)
#endif
#endif /* __XFS_REFCACHE_H__ */
......@@ -51,7 +51,7 @@
#include "xfs_bmap.h"
#include "xfs_error.h"
#include "xfs_quota.h"
#include "xfs_rw.h"
#include "xfs_refcache.h"
#include "xfs_utils.h"
#include "xfs_trans_space.h"
#include "xfs_da_btree.h"
......@@ -627,6 +627,7 @@ xfs_rename(
*/
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
if (target_ip != NULL) {
xfs_refcache_purge_ip(target_ip);
IRELE(target_ip);
}
/*
......
......@@ -60,6 +60,7 @@
#include "xfs_bmap.h"
#include "xfs_da_btree.h"
#include "xfs_rw.h"
#include "xfs_refcache.h"
#include "xfs_buf_item.h"
#include "xfs_extfree_item.h"
#include "xfs_quota.h"
......@@ -168,6 +169,7 @@ xfs_cleanup(void)
xfs_cleanup_procfs();
xfs_sysctl_unregister();
xfs_refcache_destroy();
kmem_cache_destroy(xfs_bmap_free_item_zone);
kmem_cache_destroy(xfs_btree_cur_zone);
......@@ -523,6 +525,12 @@ xfs_unmount(
0 : DM_FLAGS_UNWANTED;
}
/*
* First blow any referenced inode from this file system
* out of the reference cache, and delete the timer.
*/
xfs_refcache_purge_mp(mp);
XFS_bflush(mp->m_ddev_targp);
error = xfs_unmount_flush(mp, 0);
if (error)
......@@ -593,6 +601,7 @@ xfs_mntupdate(
}
if (*flags & MS_RDONLY) {
xfs_refcache_purge_mp(mp);
pagebuf_delwri_flush(mp->m_ddev_targp, 0, NULL);
xfs_finish_reclaim_all(mp, 0);
......@@ -1464,9 +1473,19 @@ xfs_syncsub(
}
}
/*
* If this is the periodic sync, then kick some entries out of
* the reference cache. This ensures that idle entries are
* eventually kicked out of the cache.
*/
if (flags & SYNC_REFCACHE) {
xfs_refcache_purge_some(mp);
}
/*
* Now check to see if the log needs a "dummy" transaction.
*/
if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) {
xfs_trans_t *tp;
xfs_inode_t *ip;
......
......@@ -59,6 +59,7 @@
#include "xfs_da_btree.h"
#include "xfs_attr.h"
#include "xfs_rw.h"
#include "xfs_refcache.h"
#include "xfs_error.h"
#include "xfs_bit.h"
#include "xfs_rtalloc.h"
......@@ -1656,6 +1657,12 @@ xfs_release(
if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
return 0;
#ifdef HAVE_REFCACHE
/* If we are in the NFS reference cache then don't do this now */
if (ip->i_refcache)
return 0;
#endif
mp = ip->i_mount;
if (ip->i_d.di_nlink != 0) {
......@@ -2610,6 +2617,14 @@ xfs_remove(
goto std_return;
}
/*
* Before we drop our extra reference to the inode, purge it
* from the refcache if it is there. By waiting until afterwards
* to do the IRELE, we ensure that we won't go inactive in the
* xfs_refcache_purge_ip routine (although that would be OK).
*/
xfs_refcache_purge_ip(ip);
vn_trace_exit(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
/*
......@@ -2649,6 +2664,14 @@ xfs_remove(
cancel_flags |= XFS_TRANS_ABORT;
xfs_trans_cancel(tp, cancel_flags);
/*
* Before we drop our extra reference to the inode, purge it
* from the refcache if it is there. By waiting until afterwards
* to do the IRELE, we ensure that we won't go inactive in the
* xfs_refcache_purge_ip routine (although that would be OK).
*/
xfs_refcache_purge_ip(ip);
IRELE(ip);
goto std_return;
......@@ -3742,7 +3765,14 @@ xfs_rwunlock(
return;
ip = XFS_BHVTOI(bdp);
if (locktype == VRWLOCK_WRITE) {
xfs_iunlock (ip, XFS_IOLOCK_EXCL);
/*
* In the write case, we may have added a new entry to
* the reference cache. This might store a pointer to
* an inode to be released in this inode. If it is there,
* clear the pointer and release the inode after unlocking
* this one.
*/
xfs_refcache_iunlock(ip, XFS_IOLOCK_EXCL);
} else {
ASSERT((locktype == VRWLOCK_READ) ||
(locktype == VRWLOCK_WRITE_DIRECT));
......
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