cleanup dmapi filesystem interface
PATCH 1/1 cleanup dmapi filesystem interface
Currently the filesystem passes in a small operation vector where the most important method is one to obtain more methods in a really awkward way and the file_system_type as a search key. Changes this to one single operation vector (renamed to struct dmapi_operations) taht includes all methods and the search key.
Inside the dmapi remove the utterly convoluted mess dealing with the operations and replace it with a trivial linked list that can be searched to find the right operations vector.
Note that this does not fix the existing lifetime issues where the operations can go away before they are used. This is left for another patch.
fs/dmapi/dmapi_kern.h +54 -145
@@ -35,6 +35,8 @@#include <linux/fs.h> +struct dmapi_operations ; +union sys_dmapi_uarg {void *p;__u64 u;
@@ -66,27 +68,9 @@ struct dm_handle_t;#define DM_FLAGS_NDELAY 0x001/* return EAGAIN after dm_pending() */ #define DM_FLAGS_UNWANTED 0x002/* event not in fsys dm_eventset_t */ -/* Possible code levels reported by dm_code_level(). */ - -#define DM_CLVL_INIT 0/* DMAPI prior to X/Open compliance */ #define DM_CLVL_XOPEN 1/* X/Open compliant DMAPI */ -/* -* Filesystem operations accessed by the DMAPI core. -*/ -struct filesystem_dmapi_operations { -int (*get_fsys_vector)(struct super_block *sb,void *addr); -int (*fh_to_inode)(struct super_block *sb,struct inode **ip, -dm_fid_t *fid); -const struct file_operations * (*get_invis_ops)(struct inode *ip); -int (*inode_to_fh)(struct inode *ip,dm_fid_t *fid, -dm_fsid_t *fsid ); -void (*get_fsid)(struct super_block *sb,dm_fsid_t *fsid); -#define HAVE_DM_QUEUE_FLUSH -int (*flushing)(struct inode *ip); -}; -/* Prototypes used outside of the DMI module/directory. */
@@ -133,8 +117,6 @@ void dm_send_unmount_event(int retcode, int flags); -int dm_code_level (void ); -int dm_ip_to_handle (struct inode *ip,dm_handle_t *handlep);
@@ -146,78 +128,10 @@ int dm_release_threads( int errno);void dmapi_register ( -struct file_system_type *fstype, -struct filesystem_dmapi_operations *dmapiops); +struct dmapi_operations *dmapiops);void dmapi_unregister ( -struct file_system_type *fstype); - -int dmapi_registered ( -struct file_system_type *fstype, -struct filesystem_dmapi_operations **dmapiops); - - -/* The following prototypes and definitions are used by DMAPI as its -interface into the filesystem code. Communication between DMAPI and the -filesystem are established as follows: -1. DMAPI uses the VFS_DMAPI_FSYS_VECTOR to ask for the addresses -of all the functions within the filesystem that it may need to call. -2. The filesystem returns an array of function name/address pairs which -DMAPI builds into a function vector. -The VFS_DMAPI_FSYS_VECTOR call is only made one time for a particular -filesystem type. From then on, DMAPI uses its function vector to call the -filesystem functions directly. Functions in the array which DMAPI doesn't -recognize are ignored. A dummy function which returns ENOSYS is used for -any function that DMAPI needs but which was not provided by the filesystem. -If XFS doesn't recognize the VFS_DMAPI_FSYS_VECTOR, DMAPI assumes that it -doesn't have the X/Open support code; in this case DMAPI uses the XFS-code -originally bundled within DMAPI. - -The goal of this interface is allow incremental changes to be made to -both the filesystem and to DMAPI while minimizing inter-patch dependencies, -and to eventually allow DMAPI to support multiple filesystem types at the -same time should that become necessary. -*/ - -typedef enum { -DM_FSYS_CLEAR_INHERIT =0 , -DM_FSYS_CREATE_BY_HANDLE =1 , -DM_FSYS_DOWNGRADE_RIGHT =2 , -DM_FSYS_GET_ALLOCINFO_RVP =3 , -DM_FSYS_GET_BULKALL_RVP =4 , -DM_FSYS_GET_BULKATTR_RVP =5 , -DM_FSYS_GET_CONFIG =6 , -DM_FSYS_GET_CONFIG_EVENTS =7 , -DM_FSYS_GET_DESTROY_DMATTR =8 , -DM_FSYS_GET_DIOINFO =9 , -DM_FSYS_GET_DIRATTRS_RVP =10 , -DM_FSYS_GET_DMATTR =11 , -DM_FSYS_GET_EVENTLIST =12 , -DM_FSYS_GET_FILEATTR =13 , -DM_FSYS_GET_REGION =14 , -DM_FSYS_GETALL_DMATTR =15 , -DM_FSYS_GETALL_INHERIT =16 , -DM_FSYS_INIT_ATTRLOC =17 , -DM_FSYS_MKDIR_BY_HANDLE =18 , -DM_FSYS_PROBE_HOLE =19 , -DM_FSYS_PUNCH_HOLE =20 , -DM_FSYS_READ_INVIS_RVP =21 , -DM_FSYS_RELEASE_RIGHT =22 , -DM_FSYS_REMOVE_DMATTR =23 , -DM_FSYS_REQUEST_RIGHT =24 , -DM_FSYS_SET_DMATTR =25 , -DM_FSYS_SET_EVENTLIST =26 , -DM_FSYS_SET_FILEATTR =27 , -DM_FSYS_SET_INHERIT =28 , -DM_FSYS_SET_REGION =29 , -DM_FSYS_SYMLINK_BY_HANDLE =30 , -DM_FSYS_SYNC_BY_HANDLE =31 , -DM_FSYS_UPGRADE_RIGHT =32 , -DM_FSYS_WRITE_INVIS_RVP =33 , -DM_FSYS_OBJ_REF_HOLD =34 , -DM_FSYS_MAX =35 -}dm_fsys_switch_t ; - +struct dmapi_operations *dmapiops);#define DM_FSYS_OBJ 0x1/* object refers to a fsys handle */
@@ -466,63 +380,58 @@ typedef int (*dm_fsys_write_invis_rvp_t)typedef void (*dm_fsys_obj_ref_hold_t )(struct inode *ip); +/* +* Filesystem operations accessed by the DMAPI core. +*/ +typedef struct dmapi_operations { +struct list_head list; +struct file_system_type *fstype; -/* Structure definitions used by the VFS_DMAPI_FSYS_VECTOR call. */ - -typedef struct { -dm_fsys_switch_t func_no;/* function number */ -union { -dm_fsys_clear_inherit_t clear_inherit; -dm_fsys_create_by_handle_t create_by_handle; -dm_fsys_downgrade_right_t downgrade_right; -dm_fsys_get_allocinfo_rvp_t get_allocinfo_rvp; -dm_fsys_get_bulkall_rvp_t get_bulkall_rvp; -dm_fsys_get_bulkattr_rvp_t get_bulkattr_rvp; -dm_fsys_get_config_t get_config; -dm_fsys_get_config_events_t get_config_events; -dm_fsys_get_destroy_dmattr_t get_destroy_dmattr; -dm_fsys_get_dioinfo_t get_dioinfo; -dm_fsys_get_dirattrs_rvp_t get_dirattrs_rvp; -dm_fsys_get_dmattr_t get_dmattr; -dm_fsys_get_eventlist_t get_eventlist; -dm_fsys_get_fileattr_t get_fileattr; -dm_fsys_get_region_t get_region; -dm_fsys_getall_dmattr_t getall_dmattr; -dm_fsys_getall_inherit_t getall_inherit; -dm_fsys_init_attrloc_t init_attrloc; -dm_fsys_mkdir_by_handle_t mkdir_by_handle; -dm_fsys_probe_hole_t probe_hole; -dm_fsys_punch_hole_t punch_hole; -dm_fsys_read_invis_rvp_t read_invis_rvp; -dm_fsys_release_right_t release_right; -dm_fsys_remove_dmattr_t remove_dmattr; -dm_fsys_request_right_t request_right; -dm_fsys_set_dmattr_t set_dmattr; -dm_fsys_set_eventlist_t set_eventlist; -dm_fsys_set_fileattr_t set_fileattr; -dm_fsys_set_inherit_t set_inherit; -dm_fsys_set_region_t set_region; -dm_fsys_symlink_by_handle_t symlink_by_handle; -dm_fsys_sync_by_handle_t sync_by_handle; -dm_fsys_upgrade_right_t upgrade_right; -dm_fsys_write_invis_rvp_t write_invis_rvp; -dm_fsys_obj_ref_hold_t obj_ref_hold; - } u_fc; -}fsys_function_vector_t ; - -struct dm_fcntl_vector { -int code_level; -int count;/* Number of functions in the vector */ -fsys_function_vector_t *vecp; -}; -typedef struct dm_fcntl_vector dm_fcntl_vector_t ; +int (*fh_to_inode)(struct super_block *sb,struct inode **ip, +dm_fid_t *fid); +const struct file_operations * (*get_invis_ops)(struct inode *ip); +int (*inode_to_fh)(struct inode *ip,dm_fid_t *fid, +dm_fsid_t *fsid); +void (*get_fsid)(struct super_block *sb,dm_fsid_t *fsid); +#define HAVE_DM_QUEUE_FLUSH +int (*flushing)(struct inode *ip); -struct dm_fcntl_mapevent { -size_t length;/* length of transfer */ -dm_eventtype_t max_event;/* Maximum (WRITE or READ) event */ -int error;/* returned error code */ -}; -typedef struct dm_fcntl_mapevent dm_fcntl_mapevent_t ; +dm_fsys_clear_inherit_t clear_inherit; +dm_fsys_create_by_handle_t create_by_handle; +dm_fsys_downgrade_right_t downgrade_right; +dm_fsys_get_allocinfo_rvp_t get_allocinfo_rvp; +dm_fsys_get_bulkall_rvp_t get_bulkall_rvp; +dm_fsys_get_bulkattr_rvp_t get_bulkattr_rvp; +dm_fsys_get_config_t get_config; +dm_fsys_get_config_events_t get_config_events; +dm_fsys_get_destroy_dmattr_t get_destroy_dmattr; +dm_fsys_get_dioinfo_t get_dioinfo; +dm_fsys_get_dirattrs_rvp_t get_dirattrs_rvp; +dm_fsys_get_dmattr_t get_dmattr; +dm_fsys_get_eventlist_t get_eventlist; +dm_fsys_get_fileattr_t get_fileattr; +dm_fsys_get_region_t get_region; +dm_fsys_getall_dmattr_t getall_dmattr; +dm_fsys_getall_inherit_t getall_inherit; +dm_fsys_init_attrloc_t init_attrloc; +dm_fsys_mkdir_by_handle_t mkdir_by_handle; +dm_fsys_probe_hole_t probe_hole; +dm_fsys_punch_hole_t punch_hole; +dm_fsys_read_invis_rvp_t read_invis_rvp; +dm_fsys_release_right_t release_right; +dm_fsys_remove_dmattr_t remove_dmattr; +dm_fsys_request_right_t request_right; +dm_fsys_set_dmattr_t set_dmattr; +dm_fsys_set_eventlist_t set_eventlist; +dm_fsys_set_fileattr_t set_fileattr; +dm_fsys_set_inherit_t set_inherit; +dm_fsys_set_region_t set_region; +dm_fsys_symlink_by_handle_t symlink_by_handle; +dm_fsys_sync_by_handle_t sync_by_handle; +dm_fsys_upgrade_right_t upgrade_right; +dm_fsys_write_invis_rvp_t write_invis_rvp; +dm_fsys_obj_ref_hold_t obj_ref_hold; +}dm_fsys_vector_t ;#endif /* __KERNEL__ */
fs/dmapi/dmapi_mountinfo.c deleted +0 -527
527 lines not on this page · raw message
fs/xfs/dmapi/xfs_dm.c +39 -101
168 lines not on this page · raw message
fs/dmapi/dmapi_private.h +1 -60
81 lines not on this page · raw message
fs/dmapi/dmapi_sysent.c +51 -19
100 lines not on this page · raw message
fs/dmapi/dmapi_register.c +9 -10
@@ -206,7 +206,7 @@ dm_add_fsys_entry(void *msg;unsigned long lc;/* lock cookie */ dm_fsid_t fsid; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops; dops =dm_fsys_ops (sb);ASSERT (dops);
@@ -297,7 +297,7 @@ dm_change_fsys_entry(int seq_error;unsigned long lc;/* lock cookie */ dm_fsid_t fsid; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;/* Find the filesystem referenced by the sb's fsid_t. This should always succeed.
@@ -393,7 +393,7 @@ dm_remove_fsys_entry(dm_fsreg_t **fsrpp;dm_fsreg_t *fsrp;unsigned long lc;/* lock cookie */ -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;dm_fsid_t fsid; dops =dm_fsys_ops (sb);
@@ -464,7 +464,6 @@ dm_remove_fsys_entry( remove_proc_entry(buf, NULL); }#endif -dm_fsys_ops_release (sb);sv_destroy (&fsrp->fr_dispq);sv_destroy (&fsrp->fr_queue);spinlock_destroy (&fsrp->fr_lock);
@@ -506,7 +505,7 @@ dm_handle_to_ip(struct super_block *sb;struct inode *ip;int filetype; -struct filesystem_dmapi_operations *dmapiops; +struct dmapi_operations *dmapiops;if ((fsrp =dm_find_fsreg_and_lock (&handlep->ha_fsid, &lc)) ==NULL )return NULL ;
@@ -591,7 +590,7 @@ dm_ip_to_handle(dm_fid_t fid;dm_fsid_t fsid;int hsize; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops; dops =dm_fsys_ops (ip->i_sb);ASSERT (dops);
@@ -683,7 +682,7 @@ dm_waitfor_disp(dm_session_t *s;dm_fsreg_t *fsrp;dm_fsid_t fsid; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops; dops =dm_fsys_ops (sb);ASSERT (dops);
@@ -864,7 +863,7 @@ dm_path_to_hdl(struct inode *inode;size_t len;char *name; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;/* XXX get things straightened out so getname() works here? */ if (!(len =strnlen_user (path,PATH_MAX )))
@@ -940,7 +939,7 @@ dm_path_to_fshdl(struct inode *inode;size_t len;char *name; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;/* XXX get things straightened out so getname() works here? */ if (!(len =strnlen_user (path,PATH_MAX )))
@@ -1577,7 +1576,7 @@ dm_open_by_handle_rvp( }if (td_type ==DM_TDT_REG ) { -struct filesystem_dmapi_operations *dmapiops; +struct dmapi_operations *dmapiops; dmapiops =dm_fsys_ops (inodep->i_sb);if (dmapiops && dmapiops->get_invis_ops) {/* invisible operation should not change atime */
fs/dmapi/Makefile +0 -1
@@ -46,7 +46,6 @@ dmapi-y += dmapi_sysent.o \ dmapi_handle.o \ dmapi_hole.o \ dmapi_io.o \ - dmapi_mountinfo.o \ dmapi_region.o \ dmapi_register.o \ dmapi_right.o \
fs/dmapi/dmapi_event.c +1 -1
@@ -199,7 +199,7 @@ dm_sb_data( dm_right_t right) {dm_tokdata_t *tdp; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;dm_fsid_t fsid; dops =dm_fsys_ops (sb);
fs/dmapi/dmapi_session.c +2 -2
@@ -1381,7 +1381,7 @@ dm_enqueue(return tevp->te_reply; }else { -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;dm_tokdata_t *tdp;int errno =0 ;
@@ -1767,7 +1767,7 @@ dm_release_threads(int i;int found_events =0 ;dm_fsid_t fsid; -struct filesystem_dmapi_operations *dops; +struct dmapi_operations *dops;ASSERT (sb); dops =dm_fsys_ops (sb);