Project

General

Profile

Submit #2438 ยป 0001-TRIM-fixes.patch

Anonymous, 10/21/2012 09:59 PM

View differences:

sys/kern/vfs_subr.c
{ MNT_SUIDDIR, "suiddir" },
{ MNT_SOFTDEP, "soft-updates" },
{ MNT_IGNORE, "ignore" },
{ MNT_TRIM, "trim" },
{ 0, NULL}
};
int bwritten;
sys/vfs/ufs/ffs_alloc.c
struct ffs_blkfree_trim_params *tp;
tp = ctx;
lwkt_gettoken(&tp->i_devvp->v_mount->mnt_token);
ffs_blkfree_cg(tp->i_fs, tp->i_devvp, tp->i_dev, tp->i_number,
tp->i_din_uid, tp->bno, tp->size);
lwkt_reltoken(&tp->i_devvp->v_mount->mnt_token);
kfree(tp, M_TEMP);
}
......
tp = bp->b_bio1.bio_caller_info1.ptr;
TASK_INIT(&tp->task, 0, ffs_blkfree_trim_task, tp);
tp = biop->bio_caller_info1.ptr;
taskqueue_enqueue(taskqueue_swi, &tp->task);
taskqueue_enqueue(taskqueue_swi_mp, &tp->task);
biodone(biop);
}
......
void
ffs_blkfree(struct inode *ip, ufs_daddr_t bno, long size)
{
struct mount *mp = ip->i_devvp->v_mount;
struct vnode *vn = ip->i_vnode;
struct ffs_blkfree_trim_params *tp;
struct mount *mp;
if (vn == NULL) {
/* coming here through softdep w/ stored vnode's mp */
mp = ip->i_vmnt;
}
else { /* The vnode is still around */
mp = vn->v_mount;
}
if (!(mp->mnt_flag & MNT_TRIM)) {
ffs_blkfree_cg(ip->i_fs, ip->i_devvp,ip->i_dev,ip->i_number,
sys/vfs/ufs/ffs_softdep.c
freeblks->fb_uid = ip->i_uid;
freeblks->fb_previousinum = ip->i_number;
freeblks->fb_devvp = ip->i_devvp;
freeblks->fb_vmount = ITOV(ip)->v_mount;
freeblks->fb_fs = fs;
freeblks->fb_oldsize = ip->i_size;
freeblks->fb_newsize = length;
......
ufs_lbn_t baselbns[NIADDR], tmpval;
tip.i_number = freeblks->fb_previousinum;
tip.i_vnode = NULL;
tip.i_vmnt = freeblks->fb_vmount;
tip.i_devvp = freeblks->fb_devvp;
tip.i_dev = freeblks->fb_devvp->v_rdev;
tip.i_fs = freeblks->fb_fs;
sys/vfs/ufs/inode.h
struct ufs_dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
u_quad_t i_modrev; /* Revision level for NFS lease. */
struct lockf i_lockf;/* Head of byte-level lock list. */
struct mount *i_vmnt;/* Vnode's mp: for (soft-dep) blk-free */
/*
* Side effects; used during directory lookup.
*/
sys/vfs/ufs/softdep.h
ino_t fb_previousinum; /* inode of previous owner of blocks */
struct vnode *fb_devvp; /* filesystem device vnode */
struct fs *fb_fs; /* addr of superblock */
struct mount *fb_vmount; /* vnode mp */
off_t fb_oldsize; /* previous file size */
off_t fb_newsize; /* new file size */
int fb_chkcnt; /* used to check cnt of blks released */
    (1-1/1)