Add the 'vos endtrans' command
authorAndrew Deason <adeason@sinenomine.net>
Fri, 16 Oct 2009 22:12:35 +0000 (17:12 -0500)
committerDerrick Brashear <shadow|account-1000005@unknown>
Wed, 16 Dec 2009 18:57:07 +0000 (10:57 -0800)
Add a command to vos to explicitly end volume transactions. These can
happen if (for example) we segfault or the user ctrl-C's in 'vos'
before/after a volume operation, but before we AFSVolEndTrans.

Change-Id: Ie34ee1fdff917b56900f456c7cf8b1329533a7da
Reviewed-on: http://gerrit.openafs.org/870
Reviewed-by: Dan Hyde <drh@umich.edu>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Tested-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

doc/man-pages/pod1/vos.pod
doc/man-pages/pod1/vos_endtrans.pod [new file with mode: 0644]
src/volser/vos.c

index 0f48dae..d5ce51e 100644 (file)
@@ -109,6 +109,11 @@ L<B<vos status>|vos_status(1)>.
 
 =item *
 
+A command to end Volume Server transactions:
+L<B<vos endtrans>|vos_endtrans(1)>.
+
+=item *
+
 A command to change volume fields:
 L<B<vos setfields>|vos_setfields(1)>.
 
@@ -279,6 +284,7 @@ L<vos_copy(1)>,
 L<vos_create(1)>,
 L<vos_delentry(1)>,
 L<vos_dump(1)>,
+L<vos_endtrans(1)>,
 L<vos_examine(1)>,
 L<vos_help(1)>,
 L<vos_listaddrs(1)>,
diff --git a/doc/man-pages/pod1/vos_endtrans.pod b/doc/man-pages/pod1/vos_endtrans.pod
new file mode 100644 (file)
index 0000000..3f86608
--- /dev/null
@@ -0,0 +1,148 @@
+=head1 NAME
+
+vos_endtrans - Ends a volserver transaction
+
+=head1 SYNOPSIS
+
+=for html
+<div class="synopsis">
+
+B<vos endtrans> S<<< B<-server> <I<machine name>> >>>
+    S<<< B<-transaction> <I<transaction iD>> >>>
+    S<<< [B<-cell> <I<cell name>>] >>>
+    [B<-noauth>] [B<-localauth>]
+    [B<-verbose>] [B<-encrypt>] [B<-noresolve>] [B<-help>]
+
+B<vos st> S<<< B<-s> <I<machine name>> >>>
+    S<<< B<-t> <I<transaction iD>> >>>
+    S<<< [B<-c> <I<cell name>>] >>>
+    [B<-noa>] [B<-l>] [B<-v>] [B<-e>] [B<-nor>] [B<-h>]
+
+=for html
+</div>
+
+=head1 DESCRIPTION
+
+Ths B<vos endtrans> command ends a specific transaction on the Volume
+Server for a specific volume. Under normal operation this command should
+never need to be used, but it can be useful to reduce the amount of time
+a volume is offline after an accidental command, or a L<B<vos>|vos(1)>
+process crash.
+
+Many L<B<vos>|vos(1)> commands, when they interact with a volume, create
+what is called a transaction in order to perform many different
+operations on a volume. If the L<B<vos>|vos(1)> process exits uncleanly,
+transactions may still stay open for the manipulated volumes, and the
+Volume Server may deny any further operations on those volumes while the
+transactions are still open. B<vos endtrans> allows you to end these
+transactions and make the volumes usable again without needing to
+restart the volserver.
+
+To find out what transactions are running on a Volume Server and what
+their transaction IDs are, see the L<B<vos status>|vos_status(1)>
+command.
+
+=head1 CAUTIONS
+
+This command is not used during normal OpenAFS administration. If used
+improperly, this can negatively impact currently-running
+L<B<vos>|vos(1)> operations. Only run this on a transaction if you are
+certain that the program that created the transaction is no longer
+running.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-server> <I<server name>>
+
+Identifies the file server machine running the Volume Server on which to
+end the transaction. Provide the machine's IP address or its host name
+(either fully qualified or using an unambiguous abbreviation). For
+details, see L<vos(1)>.
+
+=item B<-transaction> <I<transaction ID>>
+
+Identifies which transaction to end on the Volume Server. You can get a
+listing of active transactions and their IDs from the output of
+L<B<vos status>|vos_status(1)>.
+
+=item B<-cell> <I<cell name>>
+
+Names the cell in which to run the command. Do not combine this argument
+with the B<-localauth> flag. For more details, see L<vos(1)>.
+
+=item B<-noauth>
+
+Assigns the unprivileged identity C<anonymous> to the issuer. Do not
+combine this flag with the B<-localauth> flag. For more details, see
+L<vos(1)>.
+
+=item B<-localauth>
+
+Constructs a server ticket using a key from the local
+F</usr/afs/etc/KeyFile> file. The B<vos> command interpreter presents it
+to the Volume Server and Volume Location Server during mutual
+authentication. Do not combine this flag with the B<-cell> argument or
+B<-noauth> flag. For more details, see L<vos(1)>.
+
+=item B<-verbose>
+
+Produces on the standard output stream a detailed trace of the command's
+execution. If this argument is omitted, only warnings and error messages
+appear.
+
+=item B<-encrypt>
+
+Encrypts the command so that the operation's results are not transmitted
+across the network in clear text.
+
+=item B<-noresolve>
+
+Shows all servers as IP addresses instead of the DNS name. This is very
+useful when the server address is registered as 127.0.0.1 or when dealing
+with multi-homed servers.
+
+=item B<-help>
+
+Prints the online help for this command. All other valid options are
+ignored.
+
+=back
+
+=head1 EXAMPLES
+
+The following example illustrates the kind of output that can appear
+when a volume operation was about to be attempted on the Volume Server
+on C<fs1.abc.com>, but the process performing the operation never
+actually did anything with the volume:
+
+   % vos status fs1.abc.com
+   --------------------------------------------
+   transaction: 575  created: Fri Oct 16 16:55:54 2009
+   attachFlags: offline
+   volume: 536871080 partition: /vicepb procedure: TransCreate
+   --------------------------------------------
+   % vos endtrans fs1.abc.com 575
+   % vos status fs1.abc.com
+   No active transactions on fs1.abc.com
+
+=head1 PRIVILEGE REQUIRED
+
+The issuer must be listed in the F</usr/afs/etc/UserList> file on the
+machine specified with the B<-server> argument. If the B<-localauth>
+flag is included, the issuer must instead be logged on to a server
+machine as the local superuser C<root>.
+
+=head1 SEE ALSO
+
+L<vos(1)>,
+L<vos_status(1)>
+
+=head1 COPYRIGHT
+
+Copyright 2009 Andrew Deason <adeason@sinenomine.net>
+
+This documentation is covered by the BSD License as written in the
+doc/LICENSE file. This man page was written by Andrew Deason for
+OpenAFS.
index 360e217..2df18df 100644 (file)
@@ -5669,6 +5669,39 @@ Sizes(register struct cmd_syndesc *as, void *arock)
     return 0;
 }
 
+static int
+EndTrans(register struct cmd_syndesc *as, void *arock)
+{
+    afs_int32 server, code, tid, rcode;
+    struct rx_connection *aconn;
+
+    server = GetServer(as->parms[0].items->data);
+    if (!server) {
+       fprintf(STDERR, "vos: host '%s' not found in host table\n",
+               as->parms[0].items->data);
+       return EINVAL;
+    }
+
+    code = util_GetInt32(as->parms[1].items->data, &tid);
+    if (code) {
+       fprintf(STDERR, "vos: bad integer specified for transaction ID.\n");
+       return code;
+    }
+
+    aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
+    code = AFSVolEndTrans(aconn, tid, &rcode);
+    if (!code) {
+       code = rcode;
+    }
+
+    if (code) {
+       PrintDiagnostics("endtrans", code);
+       return 1;
+    }
+
+    return 0;
+}
+
 int
 PrintDiagnostics(char *astring, afs_int32 acode)
 {
@@ -6128,6 +6161,13 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
     COMMONPARMS;
 
+    ts = cmd_CreateSyntax("endtrans", EndTrans, NULL,
+                         "end a volserver transaction");
+    cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
+    cmd_AddParm(ts, "-transaction", CMD_SINGLE, 0,
+               "transaction ID");
+    COMMONPARMS;
+
     code = cmd_Dispatch(argc, argv);
     if (rxInitDone) {
        /* Shut down the ubik_client and rx connections */