[SCM] SAMBA-CTDB repository - branch v3-0-ctdb updated -
e49f292a35298716976a479108968c1e4fd94547
Andrew Tridgell
tridge at samba.org
Mon Feb 11 03:24:06 GMT 2008
The branch, v3-0-ctdb has been updated
via e49f292a35298716976a479108968c1e4fd94547 (commit)
from ed6a5317b0a972844d0acebc67a3a4f906b6efb9 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-0-ctdb
- Log -----------------------------------------------------------------
commit e49f292a35298716976a479108968c1e4fd94547
Author: Andrew Tridgell <tridge at samba.org>
Date: Mon Feb 11 14:23:13 2008 +1100
added support for other DMAPI attribute names
This patch allows you to specify the DMAPI attribute name used for
the tsmsm module using the option:
tsmsm:dmapi value = "XXXX"
This makes this module usable with a much wider range of HSM systems.
-----------------------------------------------------------------------
Summary of changes:
source/modules/vfs_tsmsm.c | 34 ++++++++++++++++++++++++++++++----
1 files changed, 30 insertions(+), 4 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/modules/vfs_tsmsm.c b/source/modules/vfs_tsmsm.c
index 3b9b4ac..9ad9fa9 100644
--- a/source/modules/vfs_tsmsm.c
+++ b/source/modules/vfs_tsmsm.c
@@ -72,6 +72,7 @@ struct tsmsm_struct {
float online_ratio;
char *hsmscript;
const char *attrib_name;
+ const char *attrib_value;
};
static void tsmsm_free_data(void **pptr) {
@@ -109,6 +110,10 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
"dmapi attribute", DM_ATTRIB_OBJECT);
talloc_steal(tsmd, tsmd->attrib_name);
+ tsmd->attrib_value = lp_parm_talloc_string(SNUM(handle->conn), "tsmsm",
+ "dmapi value", NULL);
+ talloc_steal(tsmd, tsmd->attrib_value);
+
fres = lp_parm_const_string(SNUM(handle->conn), "tsmsm", "online ratio", NULL);
if (fres == NULL) {
tsmd->online_ratio = FILE_IS_ONLINE_RATIO;
@@ -140,7 +145,8 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle,
dm_attrname_t dmname;
int ret;
const dm_sessid_t *sessionp;
- char buf[1];
+ char *buf;
+ int buflen;
/* if the file has more than FILE_IS_ONLINE_RATIO of blocks available,
then assume it is not offline (it may not be 100%, as it could be sparse) */
@@ -173,9 +179,22 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle,
memset(&dmname, 0, sizeof(dmname));
strlcpy((char *)&dmname.an_chars[0], tsmd->attrib_name, sizeof(dmname.an_chars));
+ if (tsmd->attrib_value != NULL) {
+ buflen = strlen(tsmd->attrib_value);
+ } else {
+ buflen = 1;
+ }
+ buf = talloc_zero_size(tsmd, buflen);
+ if (buf == NULL) {
+ DEBUG(0,("out of memory in tsmsm_is_offline\n"));
+ errno = ENOMEM;
+ ret = -1;
+ goto done;
+ }
+
again:
ret = dm_get_dmattr(*sessionp, dmhandle, dmhandle_len,
- DM_NO_TOKEN, &dmname, sizeof(buf), buf, &rlen);
+ DM_NO_TOKEN, &dmname, buflen, buf, &rlen);
if (ret == -1 && errno == EINVAL) {
DEBUG(0,("Stale DMAPI session - recreating\n"));
@@ -185,11 +204,18 @@ again:
}
}
- /* its offline if the dmapi attribute exists */
- *offline = (ret == 0 || (ret == -1 && errno == E2BIG));
+ /* check if we need a specific attribute value */
+ if (tsmd->attrib_value != NULL) {
+ *offline = (ret == 0 && rlen == buflen &&
+ memcmp(buf, tsmd->attrib_value, buflen) == 0);
+ } else {
+ /* its offline if the dmapi attribute exists */
+ *offline = (ret == 0 || (ret == -1 && errno == E2BIG));
+ }
DEBUG(10,("dm_get_dmattr %s ret=%d (%s)\n", path, ret, strerror(errno)));
+ talloc_free(buf);
ret = 0;
dm_handle_free(dmhandle, dmhandle_len);
--
SAMBA-CTDB repository
More information about the samba-cvs
mailing list