Skip to contentSkip to conversation

get rid of file_count abuse

PATCH In review Christoph Hellwig 2 participants 2 messages Jun 4, 2007 – Jun 8, 2007 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 get rid of file_count abuse

A check for file_count is always a bad idea. Linux has the ->release method to deal with cleanups on last close and ->flush is only for the very rare case where we want to perform an operation on every drop of a reference to a file struct.

This patch gets rid of vop_close and surrounding code in favour of simply doing the page flushing from ->release.

fs/xfs/linux-2.6/xfs_file.c +0 -11
Index: linux-2.6/fs/xfs/linux-2.6/xfs_file.c
===================================================================
@@ -208,15 +208,6 @@ xfs_file_open(
 }
 
 STATIC int
-xfs_file_close(
-	struct file	*filp,
-	fl_owner_t	id)
-{
-	return -bhv_vop_close(vn_from_inode(filp->f_path.dentry->d_inode), 0,
-				file_count(filp) > 1 ? L_FALSE : L_TRUE, NULL);
-}
-
-STATIC int
 xfs_file_release(
 	struct inode	*inode,
 	struct file	*filp)
@@ -461,7 +452,6 @@ const struct file_operations xfs_file_op
 #endif
 	.mmap		= xfs_file_mmap,
 	.open		= xfs_file_open,
-	.flush		= xfs_file_close,
 	.release	= xfs_file_release,
 	.fsync		= xfs_file_fsync,
 #ifdef HAVE_FOP_OPEN_EXEC
@@ -484,7 +474,6 @@ const struct file_operations xfs_invis_f
 #endif
 	.mmap		= xfs_file_mmap,
 	.open		= xfs_file_open,
-	.flush		= xfs_file_close,
 	.release	= xfs_file_release,
 	.fsync		= xfs_file_fsync,
 };
fs/xfs/linux-2.6/xfs_vnode.h +0 -5
Index: linux-2.6/fs/xfs/linux-2.6/xfs_vnode.h
===================================================================
@@ -129,10 +129,7 @@ typedef enum bhv_vchange {
 	VCHANGE_FLAGS_IOEXCL_COUNT	= 4
 } bhv_vchange_t;
 
-typedef enum { L_FALSE, L_TRUE } lastclose_t;
-
 typedef int	(*vop_open_t)(bhv_desc_t *, struct cred *);
-typedef int	(*vop_close_t)(bhv_desc_t *, int, lastclose_t, struct cred *);
 typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *,
 				const struct iovec *, unsigned int,
 				loff_t *, int, struct cred *);
@@ -203,7 +200,6 @@ typedef int	(*vop_iflush_t)(bhv_desc_t *
 typedef struct bhv_vnodeops {
 	bhv_position_t  vn_position;    /* position within behavior chain */
 	vop_open_t		vop_open;
-	vop_close_t		vop_close;
 	vop_read_t		vop_read;
 	vop_write_t		vop_write;
 	vop_sendfile_t		vop_sendfile;
@@ -249,7 +245,6 @@ typedef struct bhv_vnodeops {
 #define VNHEAD(vp)	((vp)->v_bh.bh_first)
 #define VOP(op, vp)	(*((bhv_vnodeops_t *)VNHEAD(vp)->bd_ops)->op)
 #define bhv_vop_open(vp, cr)		VOP(vop_open, vp)(VNHEAD(vp),cr)
-#define bhv_vop_close(vp, f,last,cr)	VOP(vop_close, vp)(VNHEAD(vp),f,last,cr)
 #define bhv_vop_read(vp,file,iov,segs,offset,ioflags,cr)		\
 		VOP(vop_read, vp)(VNHEAD(vp),file,iov,segs,offset,ioflags,cr)
 #define bhv_vop_write(vp,file,iov,segs,offset,ioflags,cr)		\
fs/xfs/xfs_vnodeops.c +16 -31

65 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Christoph Hellwig

A check for file_count is always a bad idea. Linux has the ->release method to deal with cleanups on last close and ->flush is only for the very rare case where we want to perform an operation on every drop of a reference to a file struct.

*nod*

Quoted 2 lines

This patch gets rid of vop_close and surrounding code in favour of simply doing the page flushing from ->release.

Added to my qa tree, and mangled to move the filestreams stuff from xfs_close to xfs_release as well.

Thanks, Christoph.

Cheers,

Dave.

Signature · 3 lines
Dave Chinner
Principal Engineer
SGI Australian Software Group