[pve-devel] r5467 - in pve-cluster/trunk/data: . perl src

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Jan 31 08:15:15 CET 2011


Author: dietmar
Date: 2011-01-31 08:15:15 +0100 (Mon, 31 Jan 2011)
New Revision: 5467

Modified:
   pve-cluster/trunk/data/Makefile.in
   pve-cluster/trunk/data/perl/Makefile
   pve-cluster/trunk/data/perl/Makefile.in
   pve-cluster/trunk/data/src/cfs-plug-memdb.c
   pve-cluster/trunk/data/src/cfs-plug.c
   pve-cluster/trunk/data/src/cfs-plug.h
   pve-cluster/trunk/data/src/database.c
   pve-cluster/trunk/data/src/dcdb.c
   pve-cluster/trunk/data/src/dcdb.h
   pve-cluster/trunk/data/src/memdb.c
   pve-cluster/trunk/data/src/memdb.h
   pve-cluster/trunk/data/src/pmxcfs.c
Log:
implement utime (touch)


Modified: pve-cluster/trunk/data/Makefile.in
===================================================================
--- pve-cluster/trunk/data/Makefile.in	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/Makefile.in	2011-01-31 07:15:15 UTC (rev 5467)
@@ -34,8 +34,8 @@
 subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(top_srcdir)/configure AUTHORS ChangeLog NEWS depcomp \
-	install-sh missing
+	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+	compile depcomp install-sh missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

Modified: pve-cluster/trunk/data/perl/Makefile
===================================================================
--- pve-cluster/trunk/data/perl/Makefile	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/perl/Makefile	2011-01-31 07:15:15 UTC (rev 5467)
@@ -89,11 +89,11 @@
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/missing --run aclocal-1.11
-AMTAR = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/missing --run tar
-AUTOCONF = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/missing --run automake-1.11
+ACLOCAL = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/missing --run aclocal-1.11
+AMTAR = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/missing --run tar
+AUTOCONF = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/missing --run automake-1.11
 AWK = mawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
@@ -127,7 +127,7 @@
 LIBS = 
 LTLIBOBJS = 
 MAINT = #
-MAKEINFO = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/missing --run makeinfo
 MKDIR_P = /bin/mkdir -p
 OBJEXT = o
 PACKAGE = pve-cluster
@@ -150,10 +150,10 @@
 SQLITE3_LIBS = -lsqlite3  
 STRIP = 
 VERSION = 1.0
-abs_builddir = /home/dietmar/pve2-proxdev/pve-cluster/data/perl
-abs_srcdir = /home/dietmar/pve2-proxdev/pve-cluster/data/perl
-abs_top_builddir = /home/dietmar/pve2-proxdev/pve-cluster/data
-abs_top_srcdir = /home/dietmar/pve2-proxdev/pve-cluster/data
+abs_builddir = /home/dietmar/pve2-devel/pve-cluster/data/perl
+abs_srcdir = /home/dietmar/pve2-devel/pve-cluster/data/perl
+abs_top_builddir = /home/dietmar/pve2-devel/pve-cluster/data
+abs_top_srcdir = /home/dietmar/pve2-devel/pve-cluster/data
 ac_ct_CC = gcc
 am__include = include
 am__leading_dot = .
@@ -172,7 +172,7 @@
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/dietmar/pve2-proxdev/pve-cluster/data/install-sh
+install_sh = ${SHELL} /home/dietmar/pve2-devel/pve-cluster/data/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
@@ -192,11 +192,11 @@
 top_build_prefix = ../
 top_builddir = ..
 top_srcdir = ..
-bin_SCRIPTS = pvecm
+bin_SCRIPTS = pvecm pvecert
 LDADD = $(QB_LIBS)
 perlbindir = /usr/lib/perl5/auto/PVE/IPCC/
 IPCC_so_SOURCES = IPCC.c ppport.h
-pvelib_DATA = IPCC.pm ClusterConfig.pm
+pvelib_DATA = IPCC.pm Cluster.pm
 pvelibdir = /usr/share/perl5/PVE
 CLEANFILES = IPCC.c *~
 all: all-am

Modified: pve-cluster/trunk/data/perl/Makefile.in
===================================================================
--- pve-cluster/trunk/data/perl/Makefile.in	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/perl/Makefile.in	2011-01-31 07:15:15 UTC (rev 5467)
@@ -192,11 +192,11 @@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-bin_SCRIPTS = pvecm
+bin_SCRIPTS = pvecm pvecert
 LDADD = $(QB_LIBS)
 perlbindir = /usr/lib/perl5/auto/PVE/IPCC/
 IPCC_so_SOURCES = IPCC.c ppport.h
-pvelib_DATA = IPCC.pm ClusterConfig.pm
+pvelib_DATA = IPCC.pm Cluster.pm
 pvelibdir = /usr/share/perl5/PVE
 CLEANFILES = IPCC.c *~
 all: all-am

Modified: pve-cluster/trunk/data/src/cfs-plug-memdb.c
===================================================================
--- pve-cluster/trunk/data/src/cfs-plug-memdb.c	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/cfs-plug-memdb.c	2011-01-31 07:15:15 UTC (rev 5467)
@@ -349,6 +349,33 @@
 	return res;
 }
 
+static int cfs_plug_memdb_utimens(
+	cfs_plug_t *plug, 
+	const char *path, 
+	const struct timespec tv[2])
+{
+	g_return_val_if_fail(plug != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(plug->ops == &cfs_ops, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(path != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(tv != NULL, PARAM_CHECK_ERRNO);
+
+	int res;
+
+	cfs_plug_memdb_t *mdb = (cfs_plug_memdb_t *)plug;
+
+	res = -EIO;
+
+	uint32_t mtime = tv[1].tv_sec;
+	if (mdb->dfsm) {
+		res = dcdb_send_fuse_message(mdb->dfsm, DCDB_MESSAGE_CFS_MTIME, path, 
+					     NULL, NULL, 0, mtime, 0);
+	} else {
+		res = memdb_mtime(mdb->memdb, path, 0, mtime);
+	}
+
+	return res;
+}
+
 static int cfs_plug_memdb_statfs(cfs_plug_t *plug, const char *path, struct statvfs *stbuf)
 {
 	g_return_val_if_fail(plug != NULL, PARAM_CHECK_ERRNO);
@@ -391,6 +418,7 @@
 	.mkdir = cfs_plug_memdb_mkdir,
 	.rmdir = cfs_plug_memdb_rmdir,
 	.rename = cfs_plug_memdb_rename,
+	.utimens = cfs_plug_memdb_utimens,
 	.statfs = cfs_plug_memdb_statfs,
 #ifdef HAS_CFS_PLUG_MEMDB_LOCK
 	.lock = cfs_plug_memdb_lock,

Modified: pve-cluster/trunk/data/src/cfs-plug.c
===================================================================
--- pve-cluster/trunk/data/src/cfs-plug.c	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/cfs-plug.c	2011-01-31 07:15:15 UTC (rev 5467)
@@ -378,6 +378,25 @@
 	return ret;
 }
 
+static int cfs_plug_base_utimens(cfs_plug_t *plug, const char *path, const struct timespec tv[2])
+{
+	g_return_val_if_fail(plug != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(plug->ops == &cfs_ops, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(path != NULL, PARAM_CHECK_ERRNO);
+	g_return_val_if_fail(tv != NULL, PARAM_CHECK_ERRNO);
+
+	cfs_debug("enter cfs_plug_utimes %s", path);
+
+	int ret = -EACCES;
+
+	cfs_plug_t *base = ((cfs_plug_base_t *)plug)->base;
+
+	if (base && base->ops && base->ops->utimens)
+		ret = base->ops->utimens(base, path, tv);
+
+	return ret;
+}
+
 static int cfs_plug_base_statfs(cfs_plug_t *plug, const char *path, struct statvfs *stbuf)
 {
 	g_return_val_if_fail(plug != NULL, PARAM_CHECK_ERRNO);
@@ -497,6 +516,7 @@
 	.rmdir = cfs_plug_base_rmdir,
 	.rename = cfs_plug_base_rename,
 	.readlink = cfs_plug_base_readlink,
+	.utimens = cfs_plug_base_utimens,
 	.statfs = cfs_plug_base_statfs,
 };
 

Modified: pve-cluster/trunk/data/src/cfs-plug.h
===================================================================
--- pve-cluster/trunk/data/src/cfs-plug.h	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/cfs-plug.h	2011-01-31 07:15:15 UTC (rev 5467)
@@ -48,6 +48,7 @@
 	int (*readdir) (cfs_plug_t *, const char *, void *, fuse_fill_dir_t, off_t,
 			struct fuse_file_info *);
 	int (*create) (cfs_plug_t *, const char *, mode_t, struct fuse_file_info *);
+	int (*utimens) (cfs_plug_t *, const char *, const struct timespec tv[2]);
 	int (*statfs) (cfs_plug_t *, const char *, struct statvfs *);
 };
 

Modified: pve-cluster/trunk/data/src/database.c
===================================================================
--- pve-cluster/trunk/data/src/database.c	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/database.c	2011-01-31 07:15:15 UTC (rev 5467)
@@ -153,7 +153,7 @@
 {
 	int rc;
 
-	cfs_debug("enter bdb_backend_write_full");
+	cfs_debug("enter backend_write_inode %016zX", inode);
 
 	if ((rc = sqlite3_bind_int64(stmt, 1, inode)) !=  SQLITE_OK) {
 		cfs_critical("sqlite3_bind failed: %s\n", sqlite3_errmsg(db));

Modified: pve-cluster/trunk/data/src/dcdb.c
===================================================================
--- pve-cluster/trunk/data/src/dcdb.c	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/dcdb.c	2011-01-31 07:15:15 UTC (rev 5467)
@@ -803,6 +803,15 @@
 		if ((msg_result >= 0) && !strcmp(to, "cluster.conf"))
 			dcdb_sync_cluster_conf(memdb, dfsm_nodeid_is_local(dfsm, nodeid, pid));
 			
+	} else if (msg_type == DCDB_MESSAGE_CFS_MTIME) {
+
+		if (!dcdb_parse_fuse_message(msg, msg_len, &path, &to, &buf, 
+					     &size, &offset, &flags))
+			goto leave;
+		
+		/* Note: mtime is sent via offset field */
+		msg_result = memdb_mtime(memdb, path, nodeid, offset);
+		
 	} else {
 		goto unknown;
 	}

Modified: pve-cluster/trunk/data/src/dcdb.h
===================================================================
--- pve-cluster/trunk/data/src/dcdb.h	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/dcdb.h	2011-01-31 07:15:15 UTC (rev 5467)
@@ -37,9 +37,10 @@
 	DCDB_MESSAGE_CFS_DELETE = 3,
 	DCDB_MESSAGE_CFS_RENAME = 4,
 	DCDB_MESSAGE_CFS_CREATE = 5,
+	DCDB_MESSAGE_CFS_MTIME = 6,
 } dcdb_message_t;
 
-#define DCDB_VALID_MESSAGE_TYPE(mt) (mt >= DCDB_MESSAGE_CFS_WRITE && mt <= DCDB_MESSAGE_CFS_CREATE)
+#define DCDB_VALID_MESSAGE_TYPE(mt) (mt >= DCDB_MESSAGE_CFS_WRITE && mt <= DCDB_MESSAGE_CFS_MTIME)
 
 dfsm_t *dcdb_new(memdb_t *memdb);
 

Modified: pve-cluster/trunk/data/src/memdb.c
===================================================================
--- pve-cluster/trunk/data/src/memdb.c	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/memdb.c	2011-01-31 07:15:15 UTC (rev 5467)
@@ -724,6 +724,85 @@
 }
 
 int 
+memdb_mtime(
+	memdb_t *memdb, 
+	const char *path, 
+	guint32 writer, 
+	guint32 mtime)
+{
+	g_return_val_if_fail(memdb != NULL, -EINVAL);
+	g_return_val_if_fail(path != NULL, -EINVAL);
+
+	int ret = -EACCES;
+
+	char *dirname = NULL;
+	char *base = NULL;
+
+	g_mutex_lock (memdb->mutex);
+
+	if (memdb->errors) {
+		ret = -EIO;
+		goto ret;
+	}
+
+	split_path(path, &dirname, &base);
+
+	memdb_tree_entry_t *parent, *unused;
+	if (!(parent = memdb_lookup_path(memdb, dirname, &unused))) {
+		ret = -ENOENT;
+		goto ret;
+	}
+	if (parent->type != DT_DIR) {
+		ret = -ENOTDIR;
+		goto ret;
+	}
+
+	/* do not allow '.' and '..' */
+	if ((base[0] == 0) ||
+	    (base[0] == '.' && base[1] == 0) ||
+	    (base[0] == '.' && base[1] == '.' && base[2] == 0)) {
+		ret = -EACCES;		
+		goto ret;
+	}
+
+	memdb_tree_entry_t *te;
+	if (!(te = memdb_lookup_dir_entry(memdb, base, parent))) {
+		ret = -ENOENT;
+		goto ret;
+	}
+
+	memdb->root->version++;
+	memdb->root->mtime = mtime;
+	memdb->root->writer = writer;
+
+	te->version = memdb->root->version;
+	te->writer = writer;
+	te->mtime = mtime;
+
+	record_memdb_change(path);
+
+	cfs_debug("memdb_mtime %s %s %016zX %016zX", dirname, te->name, te->inode, te->version);
+
+	if (bdb_backend_write(memdb->bdb, te->inode, te->parent, te->version, 
+			      te->writer, te->mtime, te->size, te->type, te->name, 
+			      te->data.value, 0)) {
+		memdb->errors = 1;
+		ret = -EIO;
+		goto ret;
+	}
+
+	ret = 0;
+
+ ret:
+	g_mutex_unlock (memdb->mutex);
+
+	if (dirname) g_free (dirname);
+	if (base) g_free (base);
+
+	return ret;
+}
+
+int 
 memdb_create(
 	memdb_t *memdb, 
 	const char *path,

Modified: pve-cluster/trunk/data/src/memdb.h
===================================================================
--- pve-cluster/trunk/data/src/memdb.h	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/memdb.h	2011-01-31 07:15:15 UTC (rev 5467)
@@ -99,6 +99,13 @@
 	guint32 writer, 
 	guint32 mtime);
 
+int 
+memdb_mtime(
+	memdb_t *memdb, 
+	const char *path, 
+	guint32 writer, 
+	guint32 mtime);
+
 GList *memdb_readdir(
 	memdb_t *memdb, 
 	const char *path);

Modified: pve-cluster/trunk/data/src/pmxcfs.c
===================================================================
--- pve-cluster/trunk/data/src/pmxcfs.c	2011-01-28 14:20:26 UTC (rev 5466)
+++ pve-cluster/trunk/data/src/pmxcfs.c	2011-01-31 07:15:15 UTC (rev 5467)
@@ -434,7 +434,30 @@
 	return ret;
 }
 
+static int cfs_fuse_utimens(const char *path, const struct timespec tv[2])
+{
+	cfs_debug("enter cfs_fuse_utimens %s", path);
 
+	int ret = -EACCES;
+
+	char *subpath = NULL;
+	cfs_plug_t *plug = find_plug(path, &subpath);
+	
+	if (!plug)
+		goto ret;
+
+	if (plug->ops && plug->ops->utimens)
+		ret = plug->ops->utimens(plug, subpath ? subpath : "", tv);
+	
+ret:
+	cfs_debug("leave cfs_fuse_utimens %s (%d)", path, ret);
+
+	if (subpath)
+		g_free(subpath);
+
+	return ret;
+}
+
 static int cfs_fuse_statfs(const char *path, struct statvfs *stbuf)
 {
 	g_return_val_if_fail(root_plug != NULL, PARAM_CHECK_ERRNO);
@@ -462,6 +485,7 @@
 	.create = cfs_fuse_create,
 	.unlink = cfs_fuse_unlink,
 	.readlink = cfs_fuse_readlink,
+	.utimens = cfs_fuse_utimens,
 	.statfs = cfs_fuse_statfs,
 	.init = cfs_fuse_init
 };



More information about the pve-devel mailing list