diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-03-18 08:41:40 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-03-18 08:41:40 +0000 |
commit | 3329e125cf06ac40cb358f404336e99b4adcf3e7 (patch) | |
tree | 77e15a9497e62ec76d0fbbe47d8521d52901883c | |
parent | 7488d466afbfdc2d90cc976fe448d50e3ec0c7c7 (diff) | |
parent | 73cca2d282fdcad473686a2aa6f567c7d19c98b3 (diff) | |
download | obnam-3329e125cf06ac40cb358f404336e99b4adcf3e7.tar.gz |
Merge branch 'liw/fuse-64k-bug'
-rw-r--r-- | NEWS | 10 | ||||
-rwxr-xr-x | mkdata | 59 | ||||
-rw-r--r-- | obnamlib/plugins/fuse_plugin.py | 11 | ||||
-rw-r--r-- | yarns/0100-fuse.yarn | 23 | ||||
-rw-r--r-- | yarns/9000-implements.yarn | 5 |
5 files changed, 103 insertions, 5 deletions
@@ -3,6 +3,16 @@ Obnam NEWS This file summarizes changes between releases of Obnam. +Version 1.8, released UNRELEASED +-------------------------------- + +Bug fixes: + +* Nemo Inis found a bug in the FUSE plugin (`obnam mount`), where + Obnam would return the wrong data when the program reading the file + didn't read the whole file from the beginning in one read(2) system + call. + Version 1.7, released 2014-03-15 -------------------------------- @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# Copyright 2014 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# =*= License: GPL-3+ =*= + + +'''Create files of specified size, filled with junk.''' + + +import os + +import cliapp + + +class MakeData(cliapp.Application): + + def add_settings(self): + self.settings.bytesize( + ['size'], + 'how large a file to generate', + default=0) + + def process_args(self, filenames): + for filename in filenames: + self.create_file(filename, self.settings['size']) + + def create_file(self, filename, size): + self.create_parent_directory(filename) + with open(filename, 'w') as f: + self.write_data(f, size) + + def create_parent_directory(self, filename): + dirname = os.path.dirname(filename) + if not os.path.exists(dirname): + os.makedirs(dirname) + + def write_data(self, f, size): + chunk = 'x' * 2**20 + written = 0 + while written < size: + n = min(len(chunk), size - written) + f.write(chunk[:n]) + written += n + + +MakeData().run() diff --git a/obnamlib/plugins/fuse_plugin.py b/obnamlib/plugins/fuse_plugin.py index 11746b86..b65e084a 100644 --- a/obnamlib/plugins/fuse_plugin.py +++ b/obnamlib/plugins/fuse_plugin.py @@ -163,20 +163,21 @@ class ObnamFuseFile(object): for chunkid in chunkids: if chunkid in size_cache: + # Don't read the contents of the chunk until later, + # in case it can be skipped completely. contents = None - size = size_cache[chunkid] else: contents = self.fuse_fs.obnam.repo.get_chunk_content(chunkid) - size = len(contents) - size_cache[chunkid] = size + size_cache[chunkid] = len(contents) + size = size_cache[chunkid] - if chunk_pos_in_file + size >= offset: + if chunk_pos_in_file + size > offset: start = offset - chunk_pos_in_file n = length - output_length if contents is None: contents = self.fuse_fs.obnam.repo.get_chunk_content( chunkid) - data = contents[start : n] + data = contents[start : start+n] output.append(data) output_length += len(data) assert output_length <= length diff --git a/yarns/0100-fuse.yarn b/yarns/0100-fuse.yarn index 0653d08e..d3433f0e 100644 --- a/yarns/0100-fuse.yarn +++ b/yarns/0100-fuse.yarn @@ -31,6 +31,20 @@ Clean up. FINALLY unmount repository F +In 2014, for Obnam 1.7, a bug was reported that the FUSE plugin would +only read the first 64 kilobytes of a file. Verify that this is no +longer a problem. + + SCENARIO restoring a big file with FUSE + ASSUMING user is in group fuse + GIVEN 1M of data in file L/big.dat + AND a manifest of L in M + WHEN user U backs up directory L to repository R + AND user U FUSE mounts the repository R at F + THEN L, restored to F/latest, matches manifest M + AND big.dat in L and in mounted F compare equally + FINALLY unmount repository F + We can only run this test if the user is in the `fuse` group. This may be a portability concern: this works in Debian GNU/Linux, but might be different in other Linux distros, or on non-Linux systems. (If it @@ -45,6 +59,15 @@ against the FUSE mount, and comparing the two manifests. run_obnam "$MATCH_1" mount -r "$DATADIR/$MATCH_2" \ --to "$DATADIR/$MATCH_3" +We also check a specific file by comparing it in the mount and in its +original location. We do the comparison with cmp(1) instead of the +usual way, because this triggered a bug. + + IMPLEMENTS THEN (\S+) in (\S+) and in mounted (\S+) compare equally + cmp \ + "$DATADIR/$MATCH_2/$MATCH_1" \ + "$DATADIR/$MATCH_3/latest/$DATADIR/$MATCH_2/$MATCH_1" + If we did do the fuse mount, **always** unmount it, even when a step failed. We do not want failed test runs to leavo mounts lying around. diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn index 2117f927..f742bdf2 100644 --- a/yarns/9000-implements.yarn +++ b/yarns/9000-implements.yarn @@ -37,6 +37,11 @@ between steps. IMPLEMENTS GIVEN (\S+) of new data in directory (\S+) genbackupdata --quiet --create "$MATCH_1" "$DATADIR/$MATCH_2" +Sometimes we need an amount of data in a specific file. + + IMPLEMENTS GIVEN (\S+) of data in file (\S+) + "$SRCDIR/mkdata" --size "$MATCH_1" "$DATADIR/$MATCH_2" + We also need to generate a sparse file. A sparse file has at least one hole in it, and it may matter where the hole is: at the beginning, middle, or end of the file. Thus, we provide a way for scenarios to |