[SCM] Samba Shared Repository - branch v4-11-test updated
Karolin Seeger
kseeger at samba.org
Tue Nov 3 11:31:02 UTC 2020
The branch, v4-11-test has been updated
via f5135703e5f s3: modules: vfs_glusterfs: Fix leak of char **lines onto mem_ctx on return.
via 28db03fbe0e s3-vfs_glusterfs: refuse connection when write-behind xlator is present
via f214862ef7a docs-xml/manpages: Add warning about write-behind translator for vfs_glusterfs
via 4352c99b18f ctdb-common: Avoid aliasing errors during code optimization
from 34af9efc6ba VERSION: Bump version up to 4.11.16.
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test
- Log -----------------------------------------------------------------
commit f5135703e5f773a57369820cf667cf046741f322
Author: Jeremy Allison <jra at samba.org>
Date: Mon Nov 2 15:46:51 2020 -0800
s3: modules: vfs_glusterfs: Fix leak of char **lines onto mem_ctx on return.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14486
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
Autobuild-Date(master): Tue Nov 3 01:56:59 UTC 2020 on sn-devel-184
(cherry picked from commit 7d846cd178d653600c71ee4bd6a491a9e48a56da)
Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
Autobuild-Date(v4-11-test): Tue Nov 3 11:30:48 UTC 2020 on sn-devel-184
commit 28db03fbe0eb3fa84038089ba32777b3fa35bff7
Author: Günther Deschner <gd at samba.org>
Date: Mon Nov 2 12:30:36 2020 +0100
s3-vfs_glusterfs: refuse connection when write-behind xlator is present
s3-vfs_glusterfs: refuse connection when write-behind xlator is present
Once the new glusterfs api is available we will programmtically disable
the translator, for now we just refuse the connection as there is
a potential for serious data damage.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14486
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
Pair-Programmed-With: Sachin Prabhu <sprabhu at redhat.com>
Pair-Programmed-With: Anoop C S <anoopcs at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Mon Nov 2 21:40:33 UTC 2020 on sn-devel-184
(cherry picked from commit 2a49ccbcf5e3ff0f6833bcb7f04b800125f1783f)
commit f214862ef7a3a6715ff19129a27c827330e03eca
Author: Sachin Prabhu <sprabhu at redhat.com>
Date: Thu Oct 15 12:14:33 2020 +0100
docs-xml/manpages: Add warning about write-behind translator for vfs_glusterfs
Add warning about data corruption with the write-behind translator.
The data corruption is highlighted by the smbtorture test smb2.rw.rw1.
More information about this data corruption issue is available in the
bz.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14486
Signed-off-by: Sachin Prabhu <sprabhu at redhat.com>
Reviewed-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Guenther Deschner <gd at samba.org>
(cherry picked from commit 08f8f665d409ee7b93840c25a8142f2ce8bacfa1)
commit 4352c99b18ff4d89de53927a8f07634f3abd94cf
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Jul 27 12:51:41 2020 +1000
ctdb-common: Avoid aliasing errors during code optimization
When compiling with GCC 10.x and -O3 optimization, the IP checksum
calculation code generates wrong checksum. The function uint16_checksum
gets inlined during optimization and ip4pkt->tcp data gets wrongly
aliased.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14537
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Wed Oct 21 05:52:28 UTC 2020 on sn-devel-184
(cherry picked from commit 6aa396b0cd1f83f45cb76a4f3123d99135e8dd8c)
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/system_socket.c | 31 ++++++------
docs-xml/manpages/vfs_glusterfs.8.xml | 22 +++++++++
source3/modules/vfs_glusterfs.c | 91 +++++++++++++++++++++++++++++++++++
3 files changed, 130 insertions(+), 14 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/system_socket.c b/ctdb/common/system_socket.c
index 86cbdaab6ad..39979d7252e 100644
--- a/ctdb/common/system_socket.c
+++ b/ctdb/common/system_socket.c
@@ -67,16 +67,19 @@
/*
uint16 checksum for n bytes
*/
-static uint32_t uint16_checksum(uint16_t *data, size_t n)
+static uint32_t uint16_checksum(uint8_t *data, size_t n)
{
uint32_t sum=0;
+ uint16_t value;
+
while (n>=2) {
- sum += (uint32_t)ntohs(*data);
- data++;
+ memcpy(&value, data, 2);
+ sum += (uint32_t)ntohs(value);
+ data += 2;
n -= 2;
}
if (n == 1) {
- sum += (uint32_t)ntohs(*(uint8_t *)data);
+ sum += (uint32_t)ntohs(*data);
}
return sum;
}
@@ -117,13 +120,13 @@ bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
/*
* simple TCP checksum - assumes data is multiple of 2 bytes long
*/
-static uint16_t ip_checksum(uint16_t *data, size_t n, struct ip *ip)
+static uint16_t ip_checksum(uint8_t *data, size_t n, struct ip *ip)
{
uint32_t sum = uint16_checksum(data, n);
uint16_t sum2;
- sum += uint16_checksum((uint16_t *)&ip->ip_src, sizeof(ip->ip_src));
- sum += uint16_checksum((uint16_t *)&ip->ip_dst, sizeof(ip->ip_dst));
+ sum += uint16_checksum((uint8_t *)&ip->ip_src, sizeof(ip->ip_src));
+ sum += uint16_checksum((uint8_t *)&ip->ip_dst, sizeof(ip->ip_dst));
sum += ip->ip_p + n;
sum = (sum & 0xFFFF) + (sum >> 16);
sum = (sum & 0xFFFF) + (sum >> 16);
@@ -135,22 +138,22 @@ static uint16_t ip_checksum(uint16_t *data, size_t n, struct ip *ip)
return sum2;
}
-static uint16_t ip6_checksum(uint16_t *data, size_t n, struct ip6_hdr *ip6)
+static uint16_t ip6_checksum(uint8_t *data, size_t n, struct ip6_hdr *ip6)
{
uint16_t phdr[3];
uint32_t sum = 0;
uint16_t sum2;
uint32_t len;
- sum += uint16_checksum((uint16_t *)(void *)&ip6->ip6_src, 16);
- sum += uint16_checksum((uint16_t *)(void *)&ip6->ip6_dst, 16);
+ sum += uint16_checksum((uint8_t *)&ip6->ip6_src, 16);
+ sum += uint16_checksum((uint8_t *)&ip6->ip6_dst, 16);
len = htonl(n);
phdr[0] = len & UINT16_MAX;
phdr[1] = (len >> 16) & UINT16_MAX;
/* ip6_nxt is only 8 bits, so fits comfortably into a uint16_t */
phdr[2] = htons(ip6->ip6_nxt);
- sum += uint16_checksum(phdr, sizeof(phdr));
+ sum += uint16_checksum((uint8_t *)phdr, sizeof(phdr));
sum += uint16_checksum(data, n);
@@ -316,7 +319,7 @@ static int ip6_na_build(uint8_t *buffer,
sizeof(struct nd_opt_hdr));
memcpy(ea, hwaddr, ETH_ALEN);
- nd_na->nd_na_cksum = ip6_checksum((uint16_t *)nd_na,
+ nd_na->nd_na_cksum = ip6_checksum((uint8_t *)nd_na,
ntohs(ip6->ip6_plen),
ip6);
@@ -556,7 +559,7 @@ static int tcp4_build(uint8_t *buf,
ip4pkt->tcp.th_off = sizeof(ip4pkt->tcp)/sizeof(uint32_t);
/* this makes it easier to spot in a sniffer */
ip4pkt->tcp.th_win = htons(1234);
- ip4pkt->tcp.th_sum = ip_checksum((uint16_t *)&ip4pkt->tcp,
+ ip4pkt->tcp.th_sum = ip_checksum((uint8_t *)&ip4pkt->tcp,
sizeof(ip4pkt->tcp),
&ip4pkt->ip);
@@ -609,7 +612,7 @@ static int tcp6_build(uint8_t *buf,
ip6pkt->tcp.th_off = sizeof(ip6pkt->tcp)/sizeof(uint32_t);
/* this makes it easier to spot in a sniffer */
ip6pkt->tcp.th_win = htons(1234);
- ip6pkt->tcp.th_sum = ip6_checksum((uint16_t *)&ip6pkt->tcp,
+ ip6pkt->tcp.th_sum = ip6_checksum((uint8_t *)&ip6pkt->tcp,
sizeof(ip6pkt->tcp),
&ip6pkt->ip6);
diff --git a/docs-xml/manpages/vfs_glusterfs.8.xml b/docs-xml/manpages/vfs_glusterfs.8.xml
index cf3b8e5e384..7a4da1af919 100644
--- a/docs-xml/manpages/vfs_glusterfs.8.xml
+++ b/docs-xml/manpages/vfs_glusterfs.8.xml
@@ -161,6 +161,28 @@
</refsect1>
+<refsect1>
+ <title>CAVEATS</title>
+
+ <para>
+ The GlusterFS write-behind performance translator, when used
+ with Samba, could be a source of data corruption. The
+ translator, while processing a write call, immediately returns
+ success but continues writing the data to the server in the
+ background. This can cause data corruption when two clients
+ relying on Samba to provide data consistency are operating on
+ the same file.
+ </para>
+ <para>
+ The write-behind translator is enabled by default on GlusterFS.
+ The vfs_glusterfs plugin will check for the presence of the
+ translator and refuse to connect if detected.
+ Please disable the write-behind translator for the GlusterFS
+ volume to allow the plugin to connect to the volume.
+ </para>
+</refsect1>
+
+
<refsect1>
<title>VERSION</title>
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index f23a8821add..747176ecebb 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -264,6 +264,92 @@ out:
/* Disk Operations */
+static int check_for_write_behind_translator(TALLOC_CTX *mem_ctx,
+ glfs_t *fs,
+ const char *volume)
+{
+ char *buf = NULL;
+ char **lines = NULL;
+ int numlines = 0;
+ int i;
+ char *option;
+ bool write_behind_present = false;
+ size_t newlen;
+ int ret;
+
+ ret = glfs_get_volfile(fs, NULL, 0);
+ if (ret == 0) {
+ DBG_ERR("%s: Failed to get volfile for "
+ "volume (%s): No volfile\n",
+ volume,
+ strerror(errno));
+ return -1;
+ }
+ if (ret > 0) {
+ DBG_ERR("%s: Invalid return %d for glfs_get_volfile for "
+ "volume (%s): No volfile\n",
+ volume,
+ ret,
+ strerror(errno));
+ return -1;
+ }
+
+ newlen = 0 - ret;
+
+ buf = talloc_zero_array(mem_ctx, char, newlen);
+ if (buf == NULL) {
+ return -1;
+ }
+
+ ret = glfs_get_volfile(fs, buf, newlen);
+ if (ret != newlen) {
+ TALLOC_FREE(buf);
+ DBG_ERR("%s: Failed to get volfile for volume (%s)\n",
+ volume, strerror(errno));
+ return -1;
+ }
+
+ option = talloc_asprintf(mem_ctx, "volume %s-write-behind", volume);
+ if (option == NULL) {
+ TALLOC_FREE(buf);
+ return -1;
+ }
+
+ lines = file_lines_parse(buf,
+ newlen,
+ &numlines,
+ mem_ctx);
+ if (lines == NULL || numlines <= 0) {
+ TALLOC_FREE(option);
+ TALLOC_FREE(buf);
+ return -1;
+ }
+
+ for (i=0; i < numlines; i++) {
+ if (strequal(lines[i], option)) {
+ write_behind_present = true;
+ break;
+ }
+ }
+
+ if (write_behind_present) {
+ DBG_ERR("Write behind translator is enabled for "
+ "volume (%s), refusing to connect! "
+ "Please check the vfs_glusterfs(8) manpage for "
+ "further details.\n",
+ volume);
+ TALLOC_FREE(lines);
+ TALLOC_FREE(option);
+ TALLOC_FREE(buf);
+ return -1;
+ }
+
+ TALLOC_FREE(lines);
+ TALLOC_FREE(option);
+ TALLOC_FREE(buf);
+ return 0;
+}
+
static int vfs_gluster_connect(struct vfs_handle_struct *handle,
const char *service,
const char *user)
@@ -348,6 +434,11 @@ static int vfs_gluster_connect(struct vfs_handle_struct *handle,
goto done;
}
+ ret = check_for_write_behind_translator(tmp_ctx, fs, volume);
+ if (ret < 0) {
+ goto done;
+ }
+
ret = glfs_set_preopened(volume, handle->conn->connectpath, fs);
if (ret < 0) {
DEBUG(0, ("%s: Failed to register volume (%s)\n",
--
Samba Shared Repository
More information about the samba-cvs
mailing list