[lkml]   [2008]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectblocks of zeros (NULLs) in NFS files in kernels >= 2.6.20
Hi all,

We're hitting some bad behavior in NFS v3. The situation is this:

machine A - NFS server

machine B - NFS client (writer)
machine C - NFS client (reader)

(all machines x86 SMP)

machine A exports a directory on ext3 filesystem:


machines B and C mount that directory normally

mount A:/srv/home /mntpnt

machine B opens a file and writes to it (think a log file)

machine C stats that file, opens it and reads it (think tailing the
log file)

The issue is that machine C will often see large blocks of NULLs
(zeros) in the file. If you do the same read again just after you see
the block of NULLs you will see proper the data.

Attached are two simple python programs that demonstrate the problem.

To use them (they will write to a file called test-nfs in CWD):

(on machine B in one window)


(on machine C in another window)

python will die when it sees NULLs in the file. Usually for us
this happens after about 60s (two timeouts I think). The first NULL is
usually either at index 4000 or 8000 depending on the kernel.

Now the version of the kernel the server is running doesn't seem to
matter. The reader also doesn't seem to matter (though I didn't test
this completely). The writer seems to be the issue:

Writer_Version Outcome:
<= 2.6.19 OK
>= 2.6.20 BAD

I've tested both vanilla kernels and Ubuntu 8.04 kernels.

I can try to bisect between 2.6.19 <-> 2.6.20.

Anyone else hitting this problem? Any better ideas?


Aaron Straus
#!/usr/bin/env python
import time
import os

def run(file_name):
data = ''
last_data_len = len(data)
last_size = os.stat(file_name).st_size

while True:
st_size = os.stat(file_name).st_size
if st_size != last_size:
print 'size changed @ %s' % time.asctime()

data = open(file_name).read()

if len(data) != last_data_len:
print 'new data arrived @ %s' % time.asctime()
print repr(data[-50:])

if '\0' in data:
first_index = data.index('\0')
data_fragment = data[first_index-50:first_index+50]
print 'Detected NULL @ %d %s' % (first_index, repr(data_fragment))


last_data_len = len(data)
last_size = st_size

if __name__ == '__main__':
#!/usr/bin/env python
import time

def run(file_name):
fp = open(file_name, 'w')

count = 1

while count:
fp.write('meow\n' * 800)


if __name__ == '__main__':
 \ /
  Last update: 2008-09-05 21:23    [W:0.113 / U:10.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site