Bug 54551 - write fails with one short >2GB write.
Summary: write fails with one short >2GB write.
Status: CLOSED DOCUMENTED
Alias: None
Product: File System
Classification: Unclassified
Component: ext4 (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Jan Kara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-27 14:49 UTC by meetmehiro
Modified: 2013-11-13 22:03 UTC (History)
2 users (show)

See Also:
Kernel Version: -
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description meetmehiro 2013-02-27 14:49:33 UTC
Hi,

I have one application where we are writing on-short 3G of data but when write succeed, it writes only 2G of data.

simple program.

if ( (ret = write(fd,buf,3221225472)) != limit) {
 
printf("\nError no:=%d",errno);
printf("\nret : %d",ret);
}

in above program, write only writes 2GB data..

could you please tell me, how to resolve this..
Comment 1 meetmehiro 2013-02-27 14:51:38 UTC
is it like, "MAX_RW_COUNT" limit is 2G ?????

is there any way, we can bypass this limit, pls help me out into this..
Comment 2 Jan Kara 2013-03-01 09:20:51 UTC
You cannot easily overcome this limit. Also I'd note that POSIX does not say how much is going to be written. So you have to be prepared for the fact that your write writes e.g. 1 byte (although in practice that doesn't tend to happen). If some program relies on write(2) writing as much as it was told to, it is a buggy program.
Comment 3 meetmehiro 2013-03-04 03:47:43 UTC
Thanks Jan Kara..

if i have space on my disk so write can write whatever number of bytes we specified.

I can able to write one short 2G , ex : write(fd,buf,2G)..

why we are not able to write one-short more-then 2G, eg: write(fd,buf,3G)??

why here "2G" limit ???
Comment 4 Jan Kara 2013-03-04 08:30:25 UTC
So that particular limit is there to avoid possible overflows within fs code. But writing really happens in page-sized (4096 bytes) chunks. If a signal comes, we stop writing so even if you write only say 16 KB you can see only 8 KB written. Now currently we stop writing only if the signal is fatal (SIGKILL or so) exactly because there are broken apps out there which could get confused by the short write but if you aim at writing reasonably clean and portable application, you should really handle short writes properly.

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