[tar/f17] Resolves #839294: Allow tar to wait for kernel leases.

Pavel Raiskup praiskup at fedoraproject.org
Fri Oct 5 17:59:42 UTC 2012


commit 17dceaf1e007ca13d8c1ca39a41e173be0d0c8a1
Author: Pavel Raiskup <praiskup at redhat.com>
Date:   Mon Jul 23 09:20:35 2012 +0200

    Resolves #839294:  Allow tar to wait for kernel leases.

 tar-1.26-lease-blocked-file.patch |  126 +++++++++++++++++++++++++++++++++++++
 tar.spec                          |   11 +++-
 2 files changed, 136 insertions(+), 1 deletions(-)
---
diff --git a/tar-1.26-lease-blocked-file.patch b/tar-1.26-lease-blocked-file.patch
new file mode 100644
index 0000000..cb0fde9
--- /dev/null
+++ b/tar-1.26-lease-blocked-file.patch
@@ -0,0 +1,126 @@
+From a53b2ee4fd159b4789363c0dd66f85ad0161f3b6 Mon Sep 17 00:00:00 2001
+From: Pavel Raiskup <praiskup at redhat.com>
+Date: Mon, 16 Jul 2012 10:37:17 +0200
+Subject: [PATCH] Try to open kernel-lease blocked file multiple times.
+
+---
+ src/common.h |    7 +++++++
+ src/create.c |   25 ++++++++++++++++++++++---
+ src/tar.c    |   26 ++++++++++++++++++++++++++
+ 3 files changed, 55 insertions(+), 3 deletions(-)
+
+diff --git a/src/common.h b/src/common.h
+index 439bf42..8dc7d6c 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -304,6 +304,13 @@ GLOBAL const char *volno_file_option;
+ 
+ /* Specified value or pattern.  */
+ GLOBAL const char *volume_label_option;
++
++/* Wait period in microseconds */
++GLOBAL int lease_period_option;
++#define DEF_LEASE_WAIT_PERIOD 10000
++
++/* Wait for lease to be unlocked at most max_wait_count_option times */
++GLOBAL int lease_wait_count_option;
+ 
+ /* Other global variables.  */
+ 
+diff --git a/src/create.c b/src/create.c
+index 1fb7eba..7cfb5e1 100644
+--- a/src/create.c
++++ b/src/create.c
+@@ -1564,6 +1564,7 @@ int
+ subfile_open (struct tar_stat_info const *dir, char const *file, int flags)
+ {
+   int fd;
++  int waited_count = 0;
+ 
+   static bool initialized;
+   if (! initialized)
+@@ -1577,9 +1578,27 @@ subfile_open (struct tar_stat_info const *dir, char const *file, int flags)
+       gettext ("");
+     }
+ 
+-  while ((fd = openat (dir ? dir->fd : chdir_fd, file, flags)) < 0
+-	 && open_failure_recover (dir))
+-    continue;
++  while ((fd = openat (dir ? dir->fd : chdir_fd, file, flags)) < 0)
++    {
++      if (open_failure_recover (dir))
++        /* try to open this file again */
++        continue;
++
++      /* check whether there is a file lease set */
++      if (lease_wait_count_option && errno == EWOULDBLOCK)
++        {
++          if (waited_count > lease_wait_count_option)
++            return -1;
++
++          usleep(lease_period_option ? lease_period_option
++                                     : DEF_LEASE_WAIT_PERIOD);
++          waited_count ++;
++          continue;
++        }
++
++      /* non recoverable */
++      break;
++    }
+   return fd;
+ }
+ 
+diff --git a/src/tar.c b/src/tar.c
+index 0669a01..4b270b4 100644
+--- a/src/tar.c
++++ b/src/tar.c
+@@ -282,6 +282,8 @@ enum
+   IGNORE_FAILED_READ_OPTION,
+   INDEX_FILE_OPTION,
+   KEEP_NEWER_FILES_OPTION,
++  LEASE_COUNT_OPTION,
++  LEASE_PERIOD_OPTION,
+   LEVEL_OPTION,
+   LZIP_OPTION,
+   LZMA_OPTION,
+@@ -447,6 +449,12 @@ static struct argp_option options[] = {
+   {"check-device", CHECK_DEVICE_OPTION, NULL, 0,
+    N_("check device numbers when creating incremental archives (default)"),
+    GRID+1 },
++  {"lease-wait-count", LEASE_COUNT_OPTION, N_("COUNT"), 0,
++   N_("wait for file lease for at most COUNT periods"),
++   GRID+1 },
++  {"lease-wait-period", LEASE_PERIOD_OPTION, N_("USECONDS"), 0,
++   N_("lease wait period in microseconds"),
++   GRID+1 },
+ #undef GRID
+ 
+ #define GRID 30
+@@ -2100,6 +2108,24 @@ parse_opt (int key, char *arg, struct argp_state *state)
+       same_permissions_option = -1;
+       break;
+ 
++    case LEASE_COUNT_OPTION:
++      {
++        char *p;
++        lease_wait_count_option = strtoul (arg, &p, 10);
++        if (*p)
++          USAGE_ERROR ((0, 0, _("Invalid lease waiting count")));
++        break;
++      }
++
++    case LEASE_PERIOD_OPTION:
++      {
++        char *p;
++        lease_period_option = strtoul (arg, &p, 10);
++        if (*p)
++          USAGE_ERROR ((0, 0, _("Invalid lease waiting count")));
++        break;
++      }
++
+     case ACLS_OPTION:
+       set_archive_format ("posix");
+       acls_option = 1;
+-- 
+1.7.10.4
+
diff --git a/tar.spec b/tar.spec
index 5e553b1..03127fb 100644
--- a/tar.spec
+++ b/tar.spec
@@ -5,7 +5,7 @@ Summary: A GNU file archiving program
 Name: tar
 Epoch: 2
 Version: 1.26
-Release: 7%{?dist}
+Release: 8%{?dist}
 License: GPLv3+
 Group: Applications/Archiving
 URL: http://www.gnu.org/software/tar/
@@ -34,6 +34,9 @@ Patch7: tar-sigpipe.patch
 Patch8: tar-1.24-openat-partial-revert.patch
 # fix for bad cooperation of -C and -u options (#688567)
 Patch9: tar-1.26-update-with-change-directory.patch
+# tar didn't try to wait for kernel lease (#839294)
+Patch10: tar-1.26-lease-blocked-file.patch
+
 BuildRequires: autoconf automake gzip texinfo gettext libacl-devel gawk rsh
 %if %{WITH_SELINUX}
 BuildRequires: libselinux-devel
@@ -66,6 +69,7 @@ the rmt package.
 %patch7 -p1 -b .fail
 %patch8 -p1 -b .openat
 %patch9 -p1 -b .update_and_changedir
+%patch10 -p1 -b .leases
 
 autoreconf
 
@@ -127,8 +131,13 @@ fi
 %{_infodir}/tar.info*
 
 %changelog
+* Mon Jul 23 2012 Pavel Raiskup <praiskup at redhat.com 2:1.26-8
+- add --lease-wait-count & --lease-wait-period options to allow tar wait for
+  kernel lease to be unlocked (#839294).
+
 * Thu Jul 12 2012 Pavel Raiskup <praiskup at redhat.com 2:1.26-7
 - force the fchown() be called before xattrs_set() (#771927)
+
 * Sat Jun 16 2012 Ondrej Vasik <ovasik at redhat.com> 2:1.26-6
 - add virtual provides for bundled(gnulib) copylib (#821790)
 - store&restore security.capability extended attributes category


More information about the scm-commits mailing list