Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1615083

Summary: generate_file_traditional() needlessly memset an array before writing into it
Product: [Community] GlusterFS Reporter: Yaniv Kaul <ykaul>
Component: stripeAssignee: bugs <bugs>
Status: CLOSED EOL QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: mainlineCC: bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-18 08:38:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yaniv Kaul 2018-08-12 07:28:20 UTC
Description of problem:
See the following code:
max_ret = 0;
		for (i = 0; i < finfo->stripe_count; i++) {
			memset(buf[i], 0, 4096);  <---- here
			ret = read(finfo->fd[i], buf[i], 4096);
			if (ret > max_ret)
				max_ret = ret;
		}
		for (i = 0; i < max_ret; i++)
			for (j = 0; j < finfo->stripe_count; j++)
				newbuf[i] |= buf[j][i];
			write(target, newbuf, max_ret);


There is no need to memset the whole 4K, we are reading from the file, writing as much as needed to it.
You should memset (4096 - ret) after reading.

Comment 1 Amar Tumballi 2018-09-18 08:38:33 UTC
Not planning to work any more on the component:

https://lists.gluster.org/pipermail/gluster-users/2018-July/034400.html