summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2008-01-29 17:43:49 +0300
committerAlexander Bokovoy <ab@samba.org>2008-01-29 17:43:49 +0300
commit28b27bfd40d1bfbebaa9f8026efdf169d7bc6b29 (patch)
tree003f7bbd01be029b98d393af5156510b6da06ac1 /source3/modules
parentef2d66bd1d1009ab4747cb4b7fc5533d44475c02 (diff)
downloadsamba-28b27bfd40d1bfbebaa9f8026efdf169d7bc6b29.tar.gz
samba-28b27bfd40d1bfbebaa9f8026efdf169d7bc6b29.tar.bz2
samba-28b27bfd40d1bfbebaa9f8026efdf169d7bc6b29.zip
Merge DMAPI fixes from Tridge
Support cases when existing DMAPI session is stale. In this case we are creating another one. The code differs from 3-0_ctdb branch in that we fail when it is not possible to create more sessions and pretend that file is offline. This allows to escape endless loop in vfs_tsmsm.c. (This used to be commit 5efb57d904e25e68b09a567e260292439ad9c095)
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_tsmsm.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/source3/modules/vfs_tsmsm.c b/source3/modules/vfs_tsmsm.c
index 40b8c3adad..3badaa3923 100644
--- a/source3/modules/vfs_tsmsm.c
+++ b/source3/modules/vfs_tsmsm.c
@@ -141,8 +141,9 @@ static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
size_t dmhandle_len = 0;
size_t rlen;
dm_attrname_t dmname;
- int ret;
+ int ret, lerrno;
bool offline;
+ char buf[1];
/* 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) */
@@ -179,8 +180,26 @@ static bool 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));
- ret = dm_get_dmattr(*dmsession_id, dmhandle, dmhandle_len,
- DM_NO_TOKEN, &dmname, 0, NULL, &rlen);
+ lerrno = 0;
+
+ do {
+ ret = dm_get_dmattr(*dmsession_id, dmhandle, dmhandle_len,
+ DM_NO_TOKEN, &dmname, sizeof(buf), buf, &rlen);
+ if (ret == -1 && errno == EINVAL) {
+ DEBUG(0, ("Stale DMAPI session, re-creating it.\n"));
+ lerrno = EINVAL;
+ if (dmapi_new_session()) {
+ sessionp = dmapi_get_current_session();
+ } else {
+ DEBUG(0,
+ ("Unable to re-create DMAPI session, assuming offline (%s) - %s\n",
+ path, strerror(errno)));
+ offline = true;
+ dm_handle_free(dmhandle, dmhandle_len);
+ goto done;
+ }
+ }
+ } while (ret == -1 && lerrno == EINVAL);
/* its offline if the specified DMAPI attribute exists */
offline = (ret == 0 || (ret == -1 && errno == E2BIG));