#include "smfs_internal.h"
struct cache_purge_param {
- int nfract; /* percentage of cache dirty to activate
- * cpurge */
- int ndirty; /* maximum number of objects to write out per
- wake-cycle */
- int interval; /* jiffies delay between cache purge */
- int nfract_sync; /* percentage of cache dirty to activate cpurge
- synchronously */
- int nfract_stop_cpurge; /* percentage of cache dirty to stop cpurge */
+ int nfract; /* Percentage of cache dirty to activate cpurge */
+ int ndirty; /* Maximum number of objects to write out per
+ wake-cycle */
+ int interval; /* jiffies delay between cache purge */
+ int nfract_sync;/* Percentage of cache dirty to activate
+ cpurge synchronously */
+ int nfract_stop_cpurge; /* Percentage of cache dirty to stop cpurge */
} cf_prm = {30, 512, 600 * HZ, 60, 20};
static struct cache_purge_queue smfs_cpq;
if (S_ISDIR(inode->i_mode)) {
if (inode->i_nlink != 2)
return 0;
- if (!strncmp(dentry->d_name.name, "lost+found",
- dentry->d_name.len))
+ if (!strncmp(dentry->d_name.name, "lost+found", dentry->d_name.len))
return 0;
LASSERT(active_entry != NULL);
get_active_entry(inode, active_entry);
return 1;
}
}
-
static int cache_pre_leaf_node(struct dentry *dentry, __u64 *active_entry, int op)
{
if (((op == 0 && dentry->d_inode->i_nlink == 0) ||
{
struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
int rc;
- ENTRY;
-
rc = fsops->fs_set_xattr(inode, handle, XATTR_SMFS_CACHE_LOGCOOKIE,
logcookie, sizeof(*logcookie));
RETURN(rc);
}
-
static int get_lru_logcookie(struct inode *inode, struct llog_cookie *logcookie)
{
struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
int rc;
-
- ENTRY;
rc = fsops->fs_get_xattr(inode, XATTR_SMFS_CACHE_LOGCOOKIE,
logcookie, sizeof(*logcookie));
RETURN(rc);
}
-static int try2purge_from_cache(struct lustre_id cid,
- struct lustre_id pid)
+static int try2purge_from_cache(struct ll_fid cfid, struct ll_fid pfid)
{
struct inode *inode, *parent;
struct super_block *sb = cpq->cpq_sb;
+ //struct llog_cookie logcookie;
__u32 hoard_priority = 0;
int rc = 0;
ENTRY;
- inode = iget(sb, cid.li_stc.u.e3s.l3s_ino);
+ inode = iget(sb, cfid.id);
if (IS_ERR(inode)) {
CERROR("not existent inode: "LPX64"/%u\n",
- cid.li_stc.u.e3s.l3s_ino,
- cid.li_stc.u.e3s.l3s_gen);
+ cfid.id, cfid.generation);
RETURN(-ENOENT);
}
- parent = iget(sb, pid.li_stc.u.e3s.l3s_ino);
+ parent = iget(sb, pfid.id);
if (IS_ERR(parent)) {
CERROR("not existent inode: "LPX64"/%u\n",
- pid.li_stc.u.e3s.l3s_ino,
- pid.li_stc.u.e3s.l3s_gen);
+ pfid.id, pfid.generation);
iput(inode);
RETURN(-ENOENT);
}
llr = (struct llog_lru_rec *)rec;
- if (try2purge_from_cache(llr->llr_cid, llr->llr_pid)==1){
+ if (try2purge_from_cache(llr->llr_cfid, llr->llr_pfid)==1){
CDEBUG(D_INODE, "purge ino/gen "LPX64"/%u from cache\n",
- llr->llr_cid.li_stc.u.e3s.l3s_ino,
- llr->llr_cid.li_stc.u.e3s.l3s_gen);
+ llr->llr_cfid.id, llr->llr_cfid.generation);
count --;
if (count == 0)
rc = LLOG_PROC_BREAK;
}
#define CFLUSH_NR 512
-
static void check_cache_space(void)
{
int state = cache_balance_state();
ENTRY;
- if (state < 0) {
- EXIT;
+ if (state < 0)
return;
- }
wakeup_cpurge();
int count = CFLUSH_NR;
purge_some_cache(&count);
}
- EXIT;
}
void cache_space_pre(struct inode *inode, int op)
/* FIXME have not used op */
check_cache_space();
-
- EXIT;
}
static int cache_space_hook_lru(struct inode *inode, struct inode *parent,
- void *handle, int op, int flags)
+ void *handle, int op, int flags)
{
struct fsfilt_operations *fsops = S2SMI(cpq->cpq_sb)->sm_fsfilt;
struct llog_ctxt *ctxt = cpq->cpq_loghandle->lgh_ctxt;
llr->llr_hdr.lrh_len = llr->llr_tail.lrt_len = sizeof(*llr);
llr->llr_hdr.lrh_type = CACHE_LRU_REC;
-
- /* FIXME-UMKA: should we setup fid components here? */
- llr->llr_cid.li_stc.u.e3s.l3s_ino = inode->i_ino;
- llr->llr_cid.li_stc.u.e3s.l3s_gen = inode->i_generation;
- llr->llr_cid.li_stc.u.e3s.l3s_type = inode->i_mode & S_IFMT;
-
- llr->llr_pid.li_stc.u.e3s.l3s_ino = parent->i_ino;
- llr->llr_pid.li_stc.u.e3s.l3s_gen = parent->i_generation;
- llr->llr_pid.li_stc.u.e3s.l3s_type = parent->i_mode & S_IFMT;
+ llr->llr_cfid.id = inode->i_ino;
+ llr->llr_cfid.generation = inode->i_generation;
+ llr->llr_cfid.f_type = inode->i_mode & S_IFMT;
+ llr->llr_pfid.id = parent->i_ino;
+ llr->llr_pfid.generation = parent->i_generation;
+ llr->llr_pfid.f_type = parent->i_mode & S_IFMT;
rc = llog_add(ctxt, &llr->llr_hdr, NULL, logcookie, 1,
NULL, NULL, NULL);
}
cpq->cpq_flags = SVC_STOPPED;
complete(&cpq->cpq_comp);
- RETURN(0);
+ return 0;
}
int cache_space_hook_setup(struct super_block *sb)
ctxt = cpq->cpq_loghandle->lgh_ctxt;
rc = llog_catalog_cleanup(ctxt);
OBD_FREE(ctxt, sizeof(*ctxt));
-
if (rc)
CERROR("failed to clean up cache lru list catalog %d\n", rc);
{
__u64 active_entry = 0;
int rc;
- ENTRY;
LASSERT(cache_leaf_node(dentry, NULL));
rc = cache_space_hook_lru(dentry->d_inode, dir, handle,
rc = set_active_entry(dir, &active_entry, handle);
RETURN(rc);
}
-
static int cache_space_hook_lookup(void *handle, struct inode *dir,
struct dentry *dentry, struct inode *new_dir,
struct dentry *new_dentry)
{
__u64 active_entry;
int rc = 0;
- ENTRY;
if (cache_leaf_node(dentry, &active_entry))
rc = cache_space_hook_lru(dentry->d_inode, dir, handle,
CACHE_SPACE_DELETE | CACHE_SPACE_INSERT,1);
RETURN(rc);
}
-
static int cache_space_hook_link(void *handle, struct inode *dir,
struct dentry *dentry, struct inode *new_dir,
struct dentry *new_dentry)
{
__u64 active_entry = 0;
int rc = 0;
- ENTRY;
if (cache_pre_leaf_node(dentry, NULL, 1)) {
rc = cache_space_hook_lru(dentry->d_inode, NULL,
}
if (cache_leaf_node(dentry->d_parent, &active_entry)) {
- rc = cache_space_hook_lru(dir, NULL, handle, CACHE_SPACE_DELETE, 0);
+ rc = cache_space_hook_lru(dir,NULL,handle,CACHE_SPACE_DELETE,0);
if (rc)
RETURN(rc);
}
rc = set_active_entry(dir, &active_entry, handle);
RETURN(rc);
}
-
static int cache_space_hook_unlink(void *handle, struct inode *dir,
struct dentry *dentry, struct inode *new_dir,
struct dentry *new_dentry)
{
__u64 active_entry;
int rc = 0;
- ENTRY;
if (cache_pre_leaf_node(dentry, NULL, 0))
rc = cache_space_hook_lru(dentry->d_inode, NULL,
handle, CACHE_SPACE_INSERT, 0);
RETURN(rc);
}
-
static int cache_space_hook_mkdir(void *handle, struct inode *dir,
struct dentry *dentry, struct inode *new_dir,
struct dentry *new_dentry)
{
__u64 active_entry;
int rc;
- ENTRY;
LASSERT(cache_leaf_node(dentry, &active_entry));
rc = cache_space_hook_lru(dentry->d_inode, dir, handle,
- CACHE_SPACE_INSERT, 0);
+ CACHE_SPACE_INSERT,0);
if (!rc && cache_pre_leaf_node(dentry->d_parent, &active_entry, 3))
- rc = cache_space_hook_lru(dir, NULL, handle, CACHE_SPACE_DELETE, 0);
+ rc = cache_space_hook_lru(dir,NULL,handle,CACHE_SPACE_DELETE,0);
RETURN(rc);
}
-
static int cache_space_hook_rmdir(void *handle, struct inode *dir,
struct dentry *dentry, struct inode *new_dir,
struct dentry *new_dentry)
{
__u64 active_entry;
int rc;
- ENTRY;
LASSERT(cache_pre_leaf_node(dentry, &active_entry, 2));
rc = cache_space_hook_lru(dentry->d_inode, NULL, handle,
handle, CACHE_SPACE_INSERT, 0);
RETURN(rc);
}
-
static int cache_space_hook_rename(void *handle, struct inode *old_dir,
- struct dentry *old_dentry, struct inode *new_dir,
- struct dentry *new_dentry)
+ struct dentry *old_dentry, struct inode *new_dir,
+ struct dentry *new_dentry)
{
__u64 active_entry;
int rc = 0;
- ENTRY;
if (new_dentry->d_inode) {
if (cache_pre_leaf_node(new_dentry, NULL, 0))
active_entry --;
if (!rc)
rc = set_active_entry(old_dir, &active_entry, handle);
- } else if (cache_pre_leaf_node(new_dentry->d_parent, &active_entry, 3)) {
+ } else if (cache_pre_leaf_node(new_dentry->d_parent, &active_entry, 3))
rc = cache_space_hook_lru(new_dir, NULL, handle,
CACHE_SPACE_DELETE, 0);
- }
- if (!rc && cache_leaf_node(old_dentry->d_parent, &active_entry)) {
+ if (!rc && cache_leaf_node(old_dentry->d_parent, &active_entry))
rc = cache_space_hook_lru(old_dir,
- old_dentry->d_parent->d_parent->d_inode,
- handle, CACHE_SPACE_INSERT, 0);
- }
-
+ old_dentry->d_parent->d_parent->d_inode,
+ handle, CACHE_SPACE_INSERT, 0);
RETURN(rc);
}
};
int cache_space_post(int op, void *handle, struct inode *old_dir,
- struct dentry *old_dentry, struct inode *new_dir,
- struct dentry *new_dentry)
+ struct dentry *old_dentry, struct inode *new_dir,
+ struct dentry *new_dentry)
{
int rc = 0;
ENTRY;