Bug 1615083 - generate_file_traditional() needlessly memset an array before writing into it
Summary: generate_file_traditional() needlessly memset an array before writing into it
Keywords:
Status: CLOSED EOL
Alias: None
Product: GlusterFS
Classification: Community
Component: stripe
Version: mainline
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: bugs@gluster.org
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-08-12 07:28 UTC by Yaniv Kaul
Modified: 2018-09-18 08:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-09-18 08:38:33 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

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


Note You need to log in before you can comment on or make changes to this bug.