Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jan 2007 22:46:57 GMT
From:      Adam Martin <adamartin@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 112695 for review
Message-ID:  <200701092246.l09Mkvbp066329@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112695

Change 112695 by adamartin@adamartin_hobbes on 2007/01/09 22:46:42

	Some changes to autofs, for protocol handling, and checking-in,
	before restructuring the way the autofs-datatypes are handled.

Affected files ...

.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#8 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#8 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#7 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.h#6 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.c#7 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.h#5 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#7 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#6 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#6 edit
.. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs_vnops.c#4 edit

Differences ...

==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#8 (text+ko) ====

@@ -56,12 +56,13 @@
 
 
 
-
-
 static int
 autofs_handle_loader( struct module *mod, int action, void *args )
 {
-	int err= 0;
+	int err;
+
+	err= 0;
+
 	switch( action )
 	{
 		case MOD_LOAD:
@@ -90,6 +91,7 @@
 			break;
 
 		case MOD_UNLOAD:
+			//cleanup_autofs();
 			destroy_dev( autofs_ctl_dev );
 			//free( autofs_ctl_state, M_AUTOFS_CTL_NODES );
 			EPRINTF( "AutoFS unloaded.\n" );
@@ -109,6 +111,7 @@
 
 
 
+#if 0
 static int
 vn_iscdev( struct vnode *vp, int *errp )
 {
@@ -139,4 +142,7 @@
 	$return ( error == 0 );
 }
 
+#endif
+
+
 DEV_MODULE( AutoFS, autofs_handle_loader, NULL );

==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#8 (text+ko) ====

@@ -64,19 +64,23 @@
 
 #define KPRINTF	EPRINTF
 
+
+/** TODO: move this to autofs_types.h **/
+
 /**************** FORWARD DEFINITIONS ******************/
 struct autofs_instance;
 struct autofs_dev_bufs;
-struct autofs_mounts;
+struct autofs_mount;
 struct vnode;
 struct pfs_node;
+struct autofs_transaction;
 
 struct proc;
 
-
+typedef struct autofs_transaction autofs_transaction_t;
 typedef struct proc kthread_t;
 typedef struct autofs_instance autofs_instance_t;
-typedef struct autofs_mounts autofs_mounts_t;
+typedef struct autofs_mount autofs_mount_t;
 
 /************** END FORWARD DEFINITIONS *****************/
 
@@ -84,26 +88,65 @@
 //typedef struct autofs_dev_bufs autofs_dev_bufs_t;
 
 
+
+/* This is needed as there's no true private field on pfs_node */
+#define	pn_priv	pn_data
+
+
 struct autofs_instance
 {
-	struct autofs_dev_bufs		*device;
-	kthread_t			*controller_thread;
+	struct autofs_dev_bufs	*device;
+	kthread_t		*controller_thread;
 
-	autofs_mounts_t			*mount_list;
+	autofs_mounts_t		*mount_list; /** This will be a hash **/
+	autofs_transaction_t	*in_flight; /** A hash of inflight
+						transactions **/
 
-	void				*extensions;
+	void			*extensions;
 };
 
 
-struct autofs_mounts
+/*** TODO: store in a hash, not a linked list. ***/
+struct autofs_mount
 {
-	autofs_mounts_t		*next;
+	/** FIXME: Not ANSI C, but I'll fix it later. **/
+	union
+	{
+		autofs_mounts_t		*next; /** This field is deprecated **/
+		uint32_t 		hash_code;
+	};
+
 	autofs_instance_t	*instance_p;
 	char			*mountpoint;
-	struct pfs_node		*mount_file; /**The pn_data field points to the autofs mount
-						structure **/
+
+	int			state;
+	unsigned long long int	flags;
+
+	struct pfs_node		*mount_file; /*	The pn_priv field points to
+						the autofs mount structure */
+
 	int			timeout;	/* Timeout in seconds */
-	int			time_remaining;	/* Time remaining until next timeout event */
+	int			time_remaining;	/* Time remaining until next
+						timeout event */
 };
 
+
+struct autofs_transaction
+{
+	uint32_t		hash_code;
+	uint32_t		transaction_id;
+	int32_t			next_expected_command;
+	struct message_header	last_message; /** This must be freed, after a successful command, with the expected transaction ID **/
+}
+
+#define AUTOFS_NODE_GET_PRIVATE( p_node )\
+		( (autofs_mount_t *) ( ( p_node )->pn_priv ) )
+
+#define AUTOFS_NODE_GET_INSTANCE( p_node )\
+		( (autofs_instance_t *)\
+		( AUTOFS_NODE_GET_PRIVATE( p_node )->instance_p ) )
+
+#define AUTOFS_NODE_GET_BUFFERS( p_node )\
+	( (autofs_instance_t *) ( AUTOFS_GET_INSTANCE( p_node )->device ) )
+
 #endif	/*** __AUTOFS_MAIN_HEADER__ ***/

==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#7 (text+ko) ====

@@ -93,7 +93,7 @@
 }
 
 static int
-create_autofs_node( int num )
+create_autofs_node( int num, autofs_instance_t *instance )
 {
 	int error;
 	struct cdevsw *autofs_cdevsw;
@@ -110,6 +110,7 @@
 	autofs_dev_data->input= autofs_queue_init();
 	autofs_dev_data->output= autofs_queue_init();
 	autofs_dev_data->instances= 0;
+	autofs_dev_data->this_instance= instance;
 
 	autofs_cdevsw->d_open= autofs_dev_open;
 	autofs_cdevsw->d_close= autofs_dev_close;

==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.h#6 (text+ko) ====


==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.c#7 (text+ko) ====

@@ -140,7 +140,8 @@
 	{
 		remains= autofs_queue_remaining( q );
 		/*
-		 * We really should do SOME kind of sleep.  This is more a spinlock
+		 * We really should do SOME kind of sleep.  This is
+		 * more a spinlock
 		 * right now.
 		 */
 	}

==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.h#5 (text+ko) ====

@@ -50,6 +50,7 @@
 
 struct autofs_dev_bufs;
 typedef struct autofs_dev_bufs autofs_dev_bufs_t;
+typedef struct autofs_dev_bufs autofs_info_t;
 
 struct autofs_dev_bufs
 {
@@ -63,6 +64,9 @@
 
 
 
+#define AUTOFS_GET_PRIVATE( p_info )\
+	 ( (autofs_info_t *) AUTOFS_GET_BUFFERS( p_info ) )
+
 #define AUTOFS_GET_BUFFERS( p_info )\
 		( AUTOFS_DEV_GET_BUFFERS( AUTOFS_GET_DEV( ( p_info ) ) ) )
 
@@ -70,6 +74,15 @@
 #define AUTOFS_DEV_GET_BUFFERS( afs_dev )\
 		( (struct autofs_dev_bufs *) ( ( afs_dev )->si_priv ) )
 
+
+#define AUTOFS_DEV_GET_INSTANCE( afs_dev )\
+		( (autofs_instance_t *) ( AUTOFS_DEV_GET_PRIVATE( \
+		afs_dev )->this_instance ) )
+
+#define AUTOFS_DEV_GET_TXNS( afs_dev )\
+		( (autofs_transaction_t *) ( AUTOFS_DEV_GET_INSTANCE( \
+		afs_dev )->in_flight ) )
+
 #define AUTOFS_GET_DEV( p_info )\
 		( (struct cdev *) ( ( p_info )->pi_priv ) )
 

==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#7 (text+ko) ====

@@ -56,13 +56,16 @@
 
 #include <fs/pseudofs/pseudofs.h>
 
+#include <sys/time.h>
+
 #include "protocol.h"
 #include "debug.h"
 #include "autofs_ctl.h"
 #include "autofs_dev.h"
 
 
-MALLOC_DEFINE(M_AUTOFS_MOUNTBUF, "AutoFS mntbuf", "AutoFS mountpoint data, to simulate filesystem contents.");
+MALLOC_DEFINE( M_AUTOFS_MOUNTBUF, "AutoFS mntbuf",
+		"AutoFS mountpoint data, to simulate filesystem contents.");
 
 struct pfs_node *foo;
 
@@ -74,23 +77,42 @@
 }
 
 static int
-autofs_attr(PFS_ATTR_ARGS)
+autofs_attr( PFS_ATTR_ARGS )
 {
 	KPRINTF( "autofs attr called\n" );
 	return 0;
 }
 
+
+static uint64_t
+generate_tid( void )
+{
+	struct timeval tm;
+
+	/** Get kernel time, to microsecond **/
+	microtime( &tm );
+
+	/** Generate a 64-bit value: concatenate seconds and useconds. **/
+	return	( uint64_t )
+			( ( tm.tv_sec << 32 ) | 
+			( tm.tv_usec ) );
+}
+
+
 static int
-autofs_lookup(PFS_LOOKUP_ARGS)
+autofs_lookup( PFS_LOOKUP_ARGS )
 {
 	struct componentname c= *cnp;
 	struct message_header	msg;
 	struct mount_request	mr;
 	struct pfs_info		*pi;
+	autofs_info_t		*instance;
 
 
 	pi=	pn->pn_info;
 
+	instance=	AUTOFS_GET_PRIVATE( pi );
+
 	DEBUG1 KPRINTF( "autofs lookup called\n" );
 	DEBUG7 KPRINTF( "cn_nameptr= %s, cn_pnbuf= %s\n", c.cn_nameptr,
 				c.cn_pnbuf );
@@ -99,7 +121,7 @@
 
 	/* Prepare a mount message */
 	msg.flags=		0;
-	msg.transaction_id=	0;
+	msg.transaction_id=	generate_tid();
 	msg.message_type=	COMMAND_MOUNT_REQUEST;
 	msg.message_data=	(char *) &mr;
 
@@ -111,7 +133,7 @@
 
 	//if( take_autofs_lock( instance, node ) )
 	//{
-		send_mount_request( &msg, AUTOFS_GET_BUFFERS( pi )->output );
+		send_mount_request( &msg, instance->output );
 	//}
 	
 	return 1;

==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#6 (text+ko) ====

@@ -37,6 +37,7 @@
 #include "autofs_dev.h"
 
 
+int process_mount_complete( struct message_header *, autofs_instance_t * );
 
 
 int
@@ -55,3 +56,21 @@
 	return 0;
 }
 
+
+#define BOGUS ( 0xDEADBEEF )
+
+int
+process_mount_complete( struct message_header *req,
+		autofs_instance_t *instance )
+{
+	
+	/* Lookup the mount ID, via TID */
+
+	/* Set mount's flags to mounted */
+
+	/* Clear the lock on the mount */
+
+	/* Send the waiting objects a wakeup */
+
+	return BOGUS;
+}

==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#6 (text+ko) ====

@@ -125,7 +125,8 @@
 
 struct mount_done {
 	uint32_t status;	/* Status of the mount-related attempt */
-	    
+	#define	STATUS_SUCCESS		( 0x00 ) /* No errors */
+	/** Other conditions should all be failures. */
 };
 
 
@@ -157,8 +158,11 @@
 
 struct greeting {
 	uint32_t status; /* The status of the greeting.  This may have future
-	    use. */
+		    use. */
 	uint32_t proto_ver; /* Kernel supported protocol. */
+
+	char	autofs_id_string[ 1024 ]; /* The CVS Id of the autofs build */
+
 	uint32_t n_mounts; /* Number of mounts to report */
 	struct managed_mount mounts[]; /* current notion of mount state */
 };

==== //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs_vnops.c#4 (text+ko) ====

@@ -411,6 +411,10 @@
 	}
 
 
+	PFS_RETURN (ENOENT);
+
+ got_pnode:
+
 	/*
 	 * ADAM Martin:
 	 * Use PFS lookup on a resolved Vnode, don't actually get
@@ -427,8 +431,6 @@
 	/**/
 
 
-	PFS_RETURN (ENOENT);
- got_pnode:
 	if (pn != pd->pn_parent && !pn->pn_parent)
 		pn->pn_parent = pd;
 	if (!pfs_visible(curthread, pn, pvd->pvd_pid, NULL)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701092246.l09Mkvbp066329>