openafs.git
3 years agoafs: Clean up afs_init.c indentation 69/14469/8
Cheyenne Wills [Wed, 23 Dec 2020 20:25:31 +0000]
afs: Clean up afs_init.c indentation

Clean up the indentation of preprocessor statements, add #endif comments
where helpful.

Clean up whitespace in code indentation.

Change-Id: Id7eeeabfea52c99f783e23468cfc89ce9ed8eae5
Reviewed-on: https://gerrit.openafs.org/14469
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agotests: fix potential divide by zero condition 01/14501/3
Cheyenne Wills [Fri, 22 Jan 2021 19:48:21 +0000]
tests: fix potential divide by zero condition

Running clang's static analysis revealed a possible divide by zero
condition.

There is a random chance of the divide by zero.

- it has to be in the first pass of the main loop testing events
  (counter = 0)
- 90% chance path :   if (counter < (NUMEVENTS -1) &&
                          random() % 10 == 0)      -- needs to be false
- 25% chance path:    if (random() % 4 == 0)       -- needs to be true

if the above conditions are met, the statement
    int victim = random() % counter
is a divide by zero.

Add a check to ensure the counter is greater than zero.  Add a comment
to document that only events prior to the current event are randomly
selected.

Change-Id: I4b4e73fa324842bb504bcc952079af15aea8a6a3
Reviewed-on: https://gerrit.openafs.org/14501
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoRemove overflow check from update_nextCid 96/14496/3
Benjamin Kaduk [Thu, 14 Jan 2021 18:20:59 +0000]
Remove overflow check from update_nextCid

The rx_nextCid global has been an unsigned type since
http://gerrit.openafs.org/11106 (which was actually merged before
the refactoring of overflow check to avoid signed integer overflow)
and thus there is no need to avoid signed overflow.  The per-connection
cid has been unsigned since the IBM import.

The natural unsigned behavior on overflow of wrapping is the desired
behvaior here, so just remove the extra logic and always increment.

Change-Id: I2d9fd24082b762eb871199da3ac1cc0983764585
Reviewed-on: https://gerrit.openafs.org/14496
Reviewed-by: Jeffrey Hutzelman <jhutz@cmu.edu>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: update_nextCid overflow handling is broken 92/14492/3
Jeffrey Altman [Thu, 14 Jan 2021 14:57:13 +0000]
rx: update_nextCid overflow handling is broken

The overflow handling in update_nextCid() produces a rx_nextCid
value of 0x80000001 which itself is out of the valid range.   When
used to construct the first call of a new connection the connection
id for the call becomes 0x80000002, and all subsequent connections
also trigger the overflow handling and thus also receive connection
id 0x80000002.

If the same connection id is used for multiple connections from
the same endpoint the accepting rx peer will be very confused.

When authenticated connections are used, the CHALLENGE/RESPONSE
will fail because of a mismatch in the connection's callNumber
array.

If an initiator makes only a single connection to a given rx peer,
that connection would succeed, but once multiple connections are
initiated all communication from a broken initiator to any rx peer
will fail.

The incorrect overflow calculation was introduced by
39b165cdda941181845022c183fea1c7af7e4356 ("Move epoch and cid
generation into the rx core").

This change corrects the overflow value to become

  1 << RX_CIDSHIFT

Change-Id: If36e3aa581d557cc0f4d2d478f84a6593224c3cc
Reviewed-on: https://gerrit.openafs.org/14492
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: rx_InitHost do not overwrite RAND_bytes rx_nextCid 91/14491/2
Jeffrey Altman [Thu, 14 Jan 2021 14:41:39 +0000]
rx: rx_InitHost do not overwrite RAND_bytes rx_nextCid

39b165cdda941181845022c183fea1c7af7e4356 ("Move epoch and cid
generation into the rx core") introduced the use of RAND_bytes()
to generate the initial 'rx_nextCid' but failed to remove the

  rx_nextCid = ((tv.tv_sec ^ tv.tv_usec) << RX_CIDSHIFT;

assignment inherited from IBM/Transarc.

At Thu, 14 Jan 2021 08:25:36 GMT the IBM inherited calculation
overflows the value CID range.   This triggers broken overflow
logic in update_nextCid().

Change-Id: Ib7283def1ded9792d394133a3969a6d86f3a6123
Reviewed-on: https://gerrit.openafs.org/14491
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Jeffrey Hutzelman <jhutz@cmu.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovolser: correctly attribute 'vos partinfo' errors 89/14489/2
Mark Vitale [Tue, 12 Jan 2021 20:50:07 +0000]
volser: correctly attribute 'vos partinfo' errors

Since the original IBM code import, the 'vos partinfo' error message
blames the wrong command, 'vos listpart':

    $ vos partinfo afs01.sinenomine.net
    <unknown>: Could not get afs tokens, running unauthenticated.
    Could not fetch the list of partitions from the server
    Possible communication failure
    Error in vos listpart command.
    Possible communication failure

Correct the error message to specify 'vos partinfo' instead.

Change-Id: I966dee8c679db89c7ed5ce21d31ebc7424803cf2
Reviewed-on: https://gerrit.openafs.org/14489
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovol: prevent salvage segfault for orphaned vnode with out-of-range parent 85/14385/3
Mark Vitale [Thu, 20 Aug 2020 20:09:02 +0000]
vol: prevent salvage segfault for orphaned vnode with out-of-range parent

While salvaging a RW volume, salvager may segfault if it encounters an
orphaned directory with a parent vnode that does not exist.  For
example, if the large vnode index contains a maximum vnode of 2901, any
parent vnode encountered that is larger than 2901 will result in an
out-of-bounds reference to our vnode essence array, leading to a
segfault or undefined behavior.

Modify the logic to check for out-of-bounds parent vnodes, and log them
rather than segfaulting.

Change-Id: I49f53935830fbb428fe0bff04c33248d3806a4b2
Reviewed-on: https://gerrit.openafs.org/14385
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: Remove SRXAFSCB_GetDE 88/14488/2
Andrew Deason [Sat, 9 Jan 2021 18:50:03 +0000]
afs: Remove SRXAFSCB_GetDE

The GetDE RPC has been commented out from afscbint.xg effectively
since it was introduced, but we still define the SRXAFSCB_GetDE server
stub for it.

This is useless, but also potentially dangerous, since the stub
routine just returns success, without populating the output arguments.
One of the output arguments is a string, and so if this RPC is
actually run, the rxgen-generated server code will try to xdr_string()
that string. Since we never set it to anything, this will result in
xdr_string trying to dereference a NULL pointer.

None of this actually happens currently, since the GetDE RPC is
commented out. But to avoid the above situation if it's ever
uncommented, remove the useless SRXAFSCB_GetDE function.

Change-Id: I6ef478ee69a8de1ac14baa86aa82489181d67452
Reviewed-on: https://gerrit.openafs.org/14488
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoWINNT: Restore missing '#ifdef PC' 87/14487/2
Andrew Deason [Sat, 9 Jan 2021 18:47:09 +0000]
WINNT: Restore missing '#ifdef PC'

Commit 339167ef (Remove dead code) meant to remove the '#ifdef notdef'
block in here, but we accidentally also removed the subsequent '#ifdef
PC'.

This file may not be very important, since WINNT still builds with
this mistake, but an unbalanced #ifdef is potentially super confusing,
so fix it.

Change-Id: I100792830e1bed0af08bcb81a34bb185b2c6358a
Reviewed-on: https://gerrit.openafs.org/14487
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoMove key-related warnings to common server code 31/10831/6
Andrew Deason [Mon, 10 Feb 2014 21:57:43 +0000]
Move key-related warnings to common server code

Each server process can log a couple of different warnings about the
server keys found on disk:

- If afsconf_GetLatestKey() returns success (indicating a single-DES
  key is present), we call LogDesWarning().

- If afsconf_CountKeys() returns 0 (indicating there are no keys at
  all on disk), we log a warning that all authenticated access will
  fail.

Currently, the code to do these checks and log the relevant warning is
duplicated across the startup code for nearly every server process. To
avoid this duplication, and to make sure the checks aren't
accidentally skipped for anyone, move these checks to
afsconf_BuildServerSecurityObjects, which every server process calls.

We must add an additional parameter to
afsconf_BuildServerSecurityObjects to handle the different logging
mechanism these servers use, but afsconf_BuildServerSecurityObjects is
declared in a public header (cellconfig.h), and is exported in a
public library (libafsauthent). So to avoid changing a public symbol,
introduce a new variant of the function, called
afsconf_BuildServerSecurityObjects_int. Declare this in a new internal
header, authcon.h.

We don't have easily-usable logging functions for upserver and butc,
so just don't log the warnings for those. For ubik servers, don't
update ubik_SetServerSecurityProcs to use the new function; the
initial call to afsconf_BuildServerSecurityObjects_int in the server's
startup code will cover logging the warning on startup.

Change-Id: I5d5fceefdaf907f96db9f1c0d21ceb6957299a59
Reviewed-on: https://gerrit.openafs.org/10831
Tested-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Split out rxi_ConnectionMatch 03/13603/9
Andrew Deason [Sun, 9 Dec 2018 00:05:36 +0000]
rx: Split out rxi_ConnectionMatch

Split out the connection-matching logic in rxi_FindConnection into a
new function called rxi_ConnectionMatch, so we can use it in other
functions in future commits.

This commit should have no visible impact; it is just code
reorganization.

Change-Id: Ibacec68d268977a8a2a3aca172653fc088334da6
Reviewed-on: https://gerrit.openafs.org/13603
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Remove unneeded rxi_ReceiveDataPacket params 02/13602/9
Andrew Deason [Sat, 8 Dec 2018 23:16:43 +0000]
rx: Remove unneeded rxi_ReceiveDataPacket params

rxi_SplitJumboPacket doesn't use its 'host', 'port', or 'first'
arguments, and rxi_ReceiveDataPacket only uses its 'host' and 'port'
arguments to pass to rxi_SplitJumboPacket.

Remove these unused parameters from both functions. While we're
changing rxi_SplitJumboPacket anyway, move the declaration for
rxi_SplitJumboPacket to rx_internal.h, so it's no longer in a public
header.

This commit should have no visible impact; it is just code
reorganization.

Change-Id: I16a7f613957d8cd2d415f65fa083e11d8a13edc8
Reviewed-on: https://gerrit.openafs.org/13602
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Avoid new server calls for big-seq DATA pkts 76/13876/7
Andrew Deason [Thu, 19 Sep 2019 17:18:08 +0000]
rx: Avoid new server calls for big-seq DATA pkts

We currently never open our receive window to more than 32 packets. If
we received a DATA packet for an unrecognized call with a seq of 33 or
more, the packet is almost certainly from a previously-running call
that we were restarted during.

As described in commit 7b204946 (rx: Avoid lastReceiveTime update for
invalid ACKs) and commit "rx: Avoid new server calls for non-DATA
packets", clients can get confused when we respond to calls in these
situations, so drop the packets instead.

Change-Id: I5b3a699bf245375e92ac97a24ad3638cbb3b8f3c
Reviewed-on: https://gerrit.openafs.org/13876
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: Fix XBSD check for VNOVAL va_uid 73/14473/2
Andrew Deason [Wed, 23 Dec 2020 18:44:35 +0000]
afs: Fix XBSD check for VNOVAL va_uid

Commit e86eb73e (obsd-vattrs-20040125) introduced an XBSD-specific
check to detect some unchanged attributes. But the #ifdef for XBSD for
the va_uid section was added in the middle of an HPUX-specific block
by mistake.

Move this #ifdef one level higher, so it's actually used on BSD
platforms.

Change-Id: I606f87f21d6c4830ed8bcf50abd6fb5807868ff5
Reviewed-on: https://gerrit.openafs.org/14473
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Avoid new server calls for non-DATA packets 58/13758/10
Mark Vitale [Thu, 8 Aug 2019 22:18:22 +0000]
rx: Avoid new server calls for non-DATA packets

Normally, a client starts a new Rx call by sending DATA packets for
that call to a server, and rxi_ReceiveServerCall on the server creates
a new call struct for that call (since we don't recognize it as an
existing call).

Under certain circumstances, it's possible for a server to see a
non-DATA packet as the first packet for a call, and currently
rxi_ReceiveServerCall will create a new server call for any packet
type. The call cannot actually proceed until the server receives data
from the client (and goes through the challenge/response auth
handshake, if needed), but usually this is harmless, since the
existence of any packets for a particular call channel indicate that
the client is trying to run such a call. The server will respond to
the client with ACKs to indicate that it is missing the needed DATA
packet(s), and the client will send them and the call can proceed.

However, if a call is in the middle of running when the server is
restarted, the client may be sending ACKs for a pre-existing call that
the server doesn't know about. In this case, the server generates ACKs
that indicate the server has not received any DATA packets, which may
appear to violate the protocol, depending on the prior state of the
call (e.g. the server appears to try to move the window backwards).

Clients should be able to detect this and kill the call, but many do
not. For many OpenAFS releases before commit 7b204946 (rx: Avoid
lastReceiveTime update for invalid ACKs), the client will get confused
in this situation and will keep the call open forever, never making
progress.

There isn't any benefit to creating a new server call in these
situations, so just ignore non-DATA packets for unrecognized calls, to
avoid stalled calls from such clients. Those clients will not get a
response from the server, and so the call will eventually die from the
normal Rx call timeout.

Change-Id: I565625ba8b6901f9b745124a8816a9ba816c0264
Reviewed-on: https://gerrit.openafs.org/13758
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Avoid lastReceiveTime update for invalid ACKs 75/13875/6
Andrew Deason [Wed, 28 Aug 2019 03:58:23 +0000]
rx: Avoid lastReceiveTime update for invalid ACKs

Currently, we ignore ACK packets in a few cases:

- If the ACK appears to move the window backwards (if firstPacket is
  smaller than call->tfirst).

- If the ACK appears to have been received out of order (if
  previousPacket is smaller than call->tprev).

- If the ACK packet appears truncated.

In all of these cases, we ignore the ACK packet completely in our ACK
processing code (rxi_ReceiveAckPacket), but we still process the
packet at higher levels (rxi_ReceivePacket). Notably, this means we
update call->lastReceiveTime after rxi_ReceiveAckPacket returns, even
for ACK packets we haven't really looked at.

Normally this does not cause any noticeable problems, because such
packets should either never be encountered, or only consist of a small
number of packets that are mixed in with valid packets.

However, if our peer is a server, and it is restarted in the middle of
a call, our peer may exclusively send us packets that fall into the
above categories. (This does not happen if our peer is a client,
because clients just ignore packets for calls they do not recognize.)
For example:

Consider a call where a client is sending data to a server, and the
server restarts after the client has sent a DATA packet with sequence
number 1000. The server may then start responding to the client with ACKs
with firstPacket set to 1, since the restarted server has no knowledge
of the call's state.

In this case, a firstPacket of 1 is well below where our window was,
so all of the ACKs from the server are ignored. But we keep updating
call->lastReceiveTime for all of these packets, and so the call stays
alive forever until an idle-dead or hard-dead timeout activates (if
any are set).

As another example, consider the case where a client is sending data
to a server, and the server receives a full window of packets (say, 16
packets), has not yet passed any data to the application yet, and the
server restarts. The restarted server then starts responding to the
client with ACKs with firstPacket set to 1, and previousPacket set to
0. We also ignore all of the ACKs from the server in this case,
because even though firstPacket looks sane, it looks like
previousPacket has gone backwards. We still update
call->lastReceiveTime for each ignored ACK we get, keeping the call
alive.

Before commit 4e71409f (Rx: Reject out of order ACK packets) was
introduced in 1.6.0, neither of these issues could occur. That commit
introduced the issue specifically if previousPacket goes backwards;
that is, if the server restarts before firstPacket moves forwards.

Commit 8d359e6d (rx: Remove duplicate out of order ACK check) in 1.8.0
introduced the issue when 'firstPacket' goes backwards, since
previously the FIRSTACKOFFSET-based check caused us to ignore those
packets without updating call->lastReceiveTime. That is, if the server
restarts after firstPacket moves forwards.

In this commit, we still ignore packets in the above cases, but we
also avoid updating lastReceiveTime when we update such packets, to
make sure that we do not keep a call alive solely from receiving these
invalid packets.

Alternatively, we could change our logic to immediately abort calls
where firstPacket moves backwards (since this violates the Rx
protocol), or to not ignore some packets where previousPacket goes
backwards (since these calls may be recoverable). And we could also
skip updating lastReceiveTime for invalid packets of other types. But
for now, this commit just avoids updating lastReceiveTime for invalid
ACK packets, in order to just try to restore our behavior before
1.6.0, while still retaining the benefits of ignoring out-of-order
ACKs. Further changes in this area can potentially be handled
separately by future commits.

Also increment the spuriousPacketsRead counter for packets that we
ignore in this way (which we used to do for some packets before commit
8d359e6d), so we are not entirely silent about ignoring them.

Written in collaboration with mvitale@sinenomine.net.

Change-Id: Ibf11bcb2417d481ab80cf4104f2862d1d6502bf4
Reviewed-on: https://gerrit.openafs.org/13875
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Introduce ack_is_valid 74/13874/6
Andrew Deason [Wed, 28 Aug 2019 22:12:53 +0000]
rx: Introduce ack_is_valid

Take some of our existing logic for ignoring invalid ACK packets and
split it out into a separate function, ack_is_valid. This just makes
it easier to add more complex logic in here and write longer comments
explaining the decisions.

Note that the bug mentioned regarding the previousPacket field was
introduced in IBM AFS 3.5, and was fixed in OpenAFS in commit bbf92017
(rx: rxi_ReceiveDataPacket do not set rprev on drop), included in
OpenAFS 1.6.23.

This commit incurs no functional change; it is just code
reorganization.

Change-Id: Idd569c6bc0c475e700935cf86780a04ab24102f4
Reviewed-on: https://gerrit.openafs.org/13874
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: For AFS_RXERRQ_ENV, retry sendmsg on error 24/14424/4
Andrew Deason [Mon, 2 Nov 2020 19:52:25 +0000]
rx: For AFS_RXERRQ_ENV, retry sendmsg on error

When AFS_RXERRQ_ENV is defined, we currently end up doing something
like this for our sendmsg abstractions:

    if (sendmsg(...) < 0) {
        while (rxi_HandleSocketError(sock))
            ;
        return error;
    }
    return success;

This means that when sendmsg() returns an error, we process the socket
error queue before returning an error.

The problem with this is that when we receive an ICMP error on our
socket, it creates a pending socket error that is returned for any
operation on the socket. So, if we receive an ICMP error after trying
to contact any peer, sendmsg() could return an error when trying to
send for any other peer. Even though there is no issue preventing us
from sending the packet, we'll fail to actually send the packet
because sendmsg() returned an error. This effectively causes an extra
outgoing packet drop, possibly delaying the related RPC.

To avoid this, change Rx to retry the sendmsg call when it returns an
error, since the error may be due to an unrelated ICMP error.

To avoid needing to implement this retry loop in multiple places, move
around our sendmsg code for AFS_RXERRQ_ENV, so that the higher-level
function rxi_NetSend performs the retry and checks for socket errors
(instead of the lower-level rxi_Sendmsg or osi_NetSend). Also change
our functions to process socket errors to be more consistent between
kernel and userspace: now we always have rxi_HandleSocketErrors, which
runs a loop around the platform-specific osi_HandleSocketError.

With this commit, osi_HandleSocketError is now required to be
implemented when AFS_RXERRQ_ENV is defined. We hadn't been
implementing this for UKERNEL, so just turn off AFS_RXERRQ_ENV for
UKERNEL.

Thanks to mbarbosa@sinenomine.net for discovering and providing
information about the relevant issue.

Change-Id: Iccceddcd2d28992ed7a00dc308816a0cb1a0195f
Reviewed-on: https://gerrit.openafs.org/14424
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agorx: Save errno in pthread rxi_Sendmsg 23/14423/3
Andrew Deason [Mon, 2 Nov 2020 19:16:41 +0000]
rx: Save errno in pthread rxi_Sendmsg

Currently, our pthread version of rxi_Sendmsg uses 'errno' in some
logic if sendmsg fails, but we do so after calling functions that
might alter errno (e.g. fflush).

To make sure we get the correct errno value, save the value of errno
right after sendmsg returns an error. Reorganize this function a bit
to help make the logic easier to follow.

Change-Id: I6bf284bd75edb5404bb6771bb99a9381b0f8654d
Reviewed-on: https://gerrit.openafs.org/14423
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafsio: readdir/fidreaddir commands 81/12381/3
Michael Meffie [Mon, 23 May 2016 00:35:26 +0000]
afsio: readdir/fidreaddir commands

Add the readdir/fidreaddir sub-commands to afsio dump AFS3 directory
objects.  This command dumps the raw directory object to stdout.  Pipe
the output to a program, such as the afsdump_dirlist program (from the
CMU dumpscan tool kit), to parse the directory object.

Example usage:

   afsio readdir -dir /afs/mycell/mypath/somedir | afsdump_dirlist

Change-Id: Ief181b432cdea6a11bbe61e781686ade2795faad
Reviewed-on: https://gerrit.openafs.org/12381
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovol: always build vol-bless utility 64/14464/2
Mark Vitale [Mon, 7 Dec 2020 19:42:54 +0000]
vol: always build vol-bless utility

In order to avoid future bit-rot, always build vol-bless.  Also add it
to the clean rule.  However, continue to leave it undistributed and
uninstalled by default.

Change-Id: I3d2dc94c28a7feeb20167223655e97538e807ce6
Reviewed-on: https://gerrit.openafs.org/14464
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFix spelling of struct rx_ackPacket in comment 68/14468/2
Benjamin Kaduk [Fri, 11 Dec 2020 19:09:20 +0000]
Fix spelling of struct rx_ackPacket in comment

A comment in rx_packet.h referred to the size of struct rx_ackpacket,
but the actual structure is spelled with a majuscule 'P'.

Change-Id: Iaf57f098b2e818fe0d492a89347a0a14bc3eb392
Reviewed-on: https://gerrit.openafs.org/14468
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Reorganize LWP rxi_Sendmsg to use 'goto error' 22/14422/2
Andrew Deason [Mon, 2 Nov 2020 19:11:49 +0000]
rx: Reorganize LWP rxi_Sendmsg to use 'goto error'

Our LWP version of rxi_Sendmsg can allocate an fd_set, but we don't
free the fd_set if sendmsg() returns certain errors afterwards.

To make sure we go through the same cleanup code for the different
possible error code paths, reorganize the function to go through a
'goto error'-style destructor. This also makes our return codes a bit
more consistent; we should always return -errno now for errors.

Change-Id: I5eaeb7f4ea1d76acc3bd9c52dc258f53f59f631e
Reviewed-on: https://gerrit.openafs.org/14422
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoaudit: Add missing AUD_TSTT case 66/14466/2
Andrew Deason [Thu, 10 Dec 2020 20:17:56 +0000]
audit: Add missing AUD_TSTT case

In commit 9ebff4c6 (OPENAFS-SA-2018-001 audit: support butc types),
several new butc-related audit data types were added. In the
AIX-specific audmakebuf() function, the case for the AUD_TSTT type is
missing the actual "case" clause in the code, causing AUD_TSTT types
to be treated as invalid (and so falling through to the
"AFS_Aud_EINVAL" case).

Add the "case" for AUD_TSTT, so it's treated properly on AIX. Note
that the non-AIX printbuf() already handled this properly, so no
changes are needed there.

Change-Id: Ic46c18b503bacb0901ff0a60534f6c45ce3c9a75
Reviewed-on: https://gerrit.openafs.org/14466
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovol: add vol-bless to .gitignore 63/14463/2
Mark Vitale [Mon, 7 Dec 2020 19:40:33 +0000]
vol: add vol-bless to .gitignore

No functional change is incurred by this commit.

Change-Id: If84ba946d43d67eb6c253462f5826f9a45a2df46
Reviewed-on: https://gerrit.openafs.org/14463
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovol: make vol-bless buildable again 62/14462/2
Mark Vitale [Mon, 7 Dec 2020 18:13:28 +0000]
vol: make vol-bless buildable again

The vol-bless utility is not built by default and so is subject to
bit-rot.  Thus commit 170dbb3ce301329ff127bb23fb588db31439ae8d 'rx: Use
opr queues' overlooked vol-bless.c when adding includes for users of
struct rx_queue.

Add the required #include <rx/rx_queue.h> so vol-bless builds again.

Note to maintainers: this change is only required for 1.8.x and later;
vol-bless builds fine in 1.6.x and earlier releases.

Change-Id: Ia0bb78e3e7dd74b2f65ac07707aced2c81aaa5d9
Reviewed-on: https://gerrit.openafs.org/14462
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: consolidate duplicated wait-for-cache-drain code 78/13278/8
Mark Vitale [Thu, 9 Aug 2018 21:40:09 +0000]
afs: consolidate duplicated wait-for-cache-drain code

Consolidate duplicated logic into a new routine
afs_MaybeWaitForCacheDrain().

Change-Id: I2e23b86eeaabe3bc559e3ddca5c1e03082af6a3f
Reviewed-on: https://gerrit.openafs.org/13278
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoafs: more cache truncation stats 68/13168/10
Michael Meffie [Mon, 20 Jun 2016 19:29:45 +0000]
afs: more cache truncation stats

Add counters for cache too full and waiting to drain occurrences. These
will be used in later commits to indicate how often the cache truncation
is required and how often the cache manager is waiting for cache
truncation to complete.

Change-Id: I4aa802729f0910dff1fb3e90b2d44d36df8bf8f3
Reviewed-on: https://gerrit.openafs.org/13168
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agokauth: Add support for updated audit facility 82/13782/28
Cheyenne Wills [Wed, 25 Sep 2019 19:39:40 +0000]
kauth: Add support for updated audit facility

New functionality was added to the audit facility that allows multiple
audit logs. The updated audit interfaces require a specific calling
sequence even if multiple audit logs are not used.

Support for multiple auditlogs is not supported for kauth. Since kauth
does not use libcmd for processing the command line, and adding support
for multiple audit log instances requires additional effort, that is not
warranted.

Update kauth to follow the proper calling sequences for the audit
facility.

Update help message and manpage entries for -auditlog and
-audit-interface.  Make note that multiple -auditlogs are not supported.

Change-Id: I98111b1e399e6687fde235bc2eadf0a28fa8acf4
Reviewed-on: https://gerrit.openafs.org/13782
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoAdd command line support for multiple audit logs 76/13776/28
Cheyenne Wills [Fri, 4 Dec 2020 17:16:57 +0000]
Add command line support for multiple audit logs

Gerrits #13774 (audit: Support multiple audit interfaces and interface
options) and #13775 (audit: Add cmd helper for processing audit options)
added support in the audit facility for multiple audit logs.

Add command line support to use multiple audit logs for daemons that use
libcmd for command line processing: bosserver, buserver, butc,
fileserver, volserver, ptserver, and vlserver.

Update the daemons to add a call to audit_open, and where possible add a
call to audit_close when shutting down the daemon.

Update help message and manpage entries for -auditlog and
-audit-interface

Change-Id: I4356e1aa84f580897a0e788e2a2829685be891aa
Reviewed-on: https://gerrit.openafs.org/13776
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoaudit: Add cmd helper for processing audit options 75/13775/24
Cheyenne Wills [Mon, 9 Nov 2020 19:27:36 +0000]
audit: Add cmd helper for processing audit options

osi_audit_cmd_Options will handle the processing for the
-audit-interface and -audit-log command line options.

The auditlog / audit-interface options are used by several services;
this new helper routine provides a simple method to process the audit
related command line options in a consistent fashion.

Change-Id: I5acd12062dbfec23c1cbb0b2cdfc2d224354eed9
Reviewed-on: https://gerrit.openafs.org/13775
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoaudit: Support multiple audit interfaces and interface options 74/13774/23
Cheyenne Wills [Fri, 13 Nov 2020 18:20:15 +0000]
audit: Support multiple audit interfaces and interface options

Currently, the audit subsystem only allows for one audit log to exist
for the entire process.  This can make it cumbersome to use for sites
that have multiple tools or destinations that want to read the audit
data. For example, to feed the audit data to two separate scripts, one
script needs to read the data, and retransmit the data to the second
script.

To make such a setup easier, change the audit system to allow for
multiple audit logs to exist at once.  To allow callers to associate
each audit log with an interface, we change the syntax for the value to
the -auditlog parameter to the following:

  [interface:]filespec[:options]

For example:

  -auditlog sysvmq:/tmp/msgqueue

To accommodate the existing -audit-interface parameter, change the
behavior of -audit-interface so that it sets the default audit interface
if none is specified for -auditlog.  This allows existing users of
-audit-interface to experience the same behavior as before.

In order to implement this, change the audit API and all existing audit
interfaces to avoid using per-interface globals, and instead allocate
per-instance contexts during startup.  Also change the code so the audit
message is constructed inside audit.c, instead of via a per-interface
callback, which eliminates the duplicated logic in each interface's
append_msg(), and lets us avoid holding 'audit_lock' during message
construction.

While we're changing the audit API, also introduce a few new operations:
open_interface, close_interface and set_options.  This commit and the
existing interfaces do not make use of these new functions, but future
commits will do so.

This commit also only changes the audit subsystem itself to be able to
handle multiple audit logs, and doesn't change any command-line parsing
logic.  Future commits will add the command-line parsing logic changes
required so daemons can actually configure multiple interfaces.

Thanks to Andrew Deason (adeason@sinenomine.net) for providing the
changes needed to reduce holding the 'audit_lock' and improve
performance as well as providing input during the development of this
change.

Change-Id: I1311ea417fdd0ba38d2206083cd65bd7a054d017
Reviewed-on: https://gerrit.openafs.org/13774
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoLINUX: Return errors in our d_revalidate 17/14417/2
Andrew Deason [Mon, 26 Oct 2020 17:35:32 +0000]
LINUX: Return errors in our d_revalidate

In our d_revalidate callback (afs_linux_dentry_revalidate), we
currently 'goto bad_dentry' when we encounter any error. This can
happen if we can't allocate memory or some other internal errors, or
if the relevant afs_lookup call fails just due to plain network
errors.

For any of these cases, we'll treat the dentry as if it's no longer
valid, so we'll return '0' and call d_invalidate() on the dentry.
However, the behavior of d_invalidate changed, as mentioned in commit
afbc199f1 (LINUX: Avoid d_invalidate() during
afs_ShakeLooseVCaches()). After a certain point in the Linux kernel,
d_invalidate() will also effectively d_drop() the given dentry,
unhashing it. This can cause getcwd() calls to fail with ENOENT for
those directories (as mentioned in afbc199f1), and can cause
bind-mount calls to fail similarly during a small window.

To avoid all of this, when we encounter an error that prevents us from
checking if the dentry is valid or not, we need to return an error,
instead of saying 'yes' or 'no'. So, change
afs_linux_dentry_revalidate to jump to the 'done' label when we
encounter such errors, and avoid calling d_drop/d_invalidate in such
cases. This also lets us remove the 'lookup_good' variable and
consolidate some of the related logic.

Important note: in older Linux kernels, d_revalidate cannot return
errors; callers just interpreted its return value as either 'valid'
(non-zero) or 'not valid' (zero). The treatment of negative values as
errors was introduced in Linux commit
bcdc5e019d9f525a9f181a7de642d3a9c27c7610, which was included in
2.6.19. This is very old, but technically still above our stated
requirements for the Linux kernel, so try to handle this case, by
jumping to 'bad_dentry' still for those old kernels. Just do this with
a version check, since no configure check can detect this (no function
signatures changed), and the only Linux versions that are a concern
are quite old.

Change-Id: Ie530ce08463cf6b6899f056cb76ae4047c989ef2
Reviewed-on: https://gerrit.openafs.org/14417
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovldb_check: Check for volume lock inconsistencies 07/14307/8
Michael Meffie [Mon, 17 Aug 2020 19:44:55 +0000]
vldb_check: Check for volume lock inconsistencies

Verify the a lock timestamp is set if, and only if, a lock volume
operation flag is also set.

When running vldb_check with the -fix option, fix the inconsistent
entries by setting the lock timestamp to the current time if a lock flag
is set, or by setting the VLOP_DELETE flag if the lock timestamp is set
but no lock flags are set. (The VLOP_DELETE flag is the flag set by the
'vos lock command, and is shown in vos output as "delete/misc".)

Volume lock fields can be put into an inconsistent state, at least, by
interupted vos rename operations, due to bugs in vos rename. When the
volume lock timestamp and lock flags are in this inconsistent state, the
volume is locked, but that is not indicated by 'vos listvldb'. The
volume can be unlocked by issuing 'vos unlock'.

Change-Id: Idc4f821a9eb7675edd78a8547fdfe46e838b0c89
Reviewed-on: https://gerrit.openafs.org/14307
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovsprocs: Remove dead code 04/14004/5
Michael Meffie [Fri, 27 Dec 2019 16:53:05 +0000]
vsprocs: Remove dead code

Remove the dead code in UV_VolumeMove() commented out with the macro
ENABLE_BUGFIX_1165.

Remove two commented out lines of code in UV_ConvertRO().

Change-Id: Ic628c74df011b0f09be6b03f72ab1baac5e59caf
Reviewed-on: https://gerrit.openafs.org/14004
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovos: Cleanup function definitions 09/14009/5
Cheyenne Wills [Thu, 5 Nov 2020 20:50:59 +0000]
vos: Cleanup function definitions

The functions defined within vos.c are not referenced outside of vos.c
but are not declared as static.

Convert the functions within vos.c to static declarations.

Change-Id: Ia684e698adc53ced964e10ee0496cb52a3af564e
Reviewed-on: https://gerrit.openafs.org/14009
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovos: Remove dead code 08/14008/5
Cheyenne Wills [Thu, 5 Nov 2020 20:49:54 +0000]
vos: Remove dead code

Clean out dead code from vos.c

GetVolumeType - not referenced anywhere
CompareVLDBEntry - commented out since 1st git commit
osi_audit - Comment indicates this might have been needed at one point.
            Builds without it.  Does not look like the vos executable
            is pulling in any of the audit code.
RestoreVolume - remove stale comment about typo previous to openafs 1.0
RemoveSite - remove commented out partition check

Change-Id: I9c0b59d5c37d403610c7a904717ac9765598fc99
Reviewed-on: https://gerrit.openafs.org/14008
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovolser: take RO volume offline during convertROtoRW 40/14340/6
Marcio Barbosa [Thu, 3 Sep 2020 23:57:34 +0000]
volser: take RO volume offline during convertROtoRW

The vos convertROtoRW command converts a RO volume into a RW volume.
Unfortunately, the RO volume is not checked out from the fileserver
during this process. As a result, accesses to the volume being converted
can leave volume objects in an inconsistent state.

Moreover, consider the following scenario:

1. Create a volume on host_b and add replicas on host_a and host_b.

$ vos create host_b a vol_1
$ vos addsite host_b a vol_1
$ vos addiste host_a a vol_1

2. Mount the volume:

$ fs mkmount /afs/.mycell/vol_1 vol_1
$ vos release vol_1
$ vos release root.cell

3. Shutdown dafs on host_b:

$ bos shutdown host_b dafs

4. Remove RO reference to host_b from the vldb:

$ vos remsite host_b a vol_1

5. Attach the RO copy by touching it:

$ fs flushall
$ ls /afs/mycell/vol_1

6. Convert RO copy to RW:

$ vos convertROtoRW host_a a vol_1

Notice that FSYNC_com_VolDone fails silently (FSYNC_BAD_STATE), leaving
the volume object for the RO copy set as VOL_STATE_ATTACHED (on success,
this volume should be set as VOL_STATE_DELETED).

7. Add replica on host_a:

$ vos addsite host_a a vol_1

8. Wait until the "inUse" flag of the RO entry is cleared (or force this
to happen by attaching multiple volumes).

9. Release the volume:

$ vos release vol_1

Failed to start transaction on volume 536870922
Volume not attached, does not exist, or not on line
Error in vos release command.
Volume not attached, does not exist, or not on line

Notice that this happens because we cannot mark an attached volume as
destroyed (FSYNC_com_VolDone).

To avoid the problem mentioned above and to prevent accesses to the
volume being converted, take the RO volume offline before converting it
to RW.

Change-Id: Ifd342e1f420dc42e5da49242a7aa70db7d97a884
Reviewed-on: https://gerrit.openafs.org/14340
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovos: Cleanup indentation whitespace 07/14007/5
Cheyenne Wills [Tue, 10 Nov 2020 16:17:16 +0000]
vos: Cleanup indentation whitespace

Fix the indentation whitespace in vos.c, and remove double blank
lines.  No functional change.

Change-Id: I97587779d6d2c131b5eac98bbee49efae73fafe9
Reviewed-on: https://gerrit.openafs.org/14007
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovos: Return true when GetServerAndPart finds a site 06/14006/4
Michael Meffie [Thu, 19 Dec 2019 01:30:17 +0000]
vos: Return true when GetServerAndPart finds a site

Change the GetServerAndPart() function to return true when a volume site
in the vldb entry is found. Do not change the output arguments unless
the site is found.  Also, add a function comment header and fix some
comment typos in this function.

Change-Id: I10b43054b1bf9e6757ccdc95cb4559ab8b6dc013
Reviewed-on: https://gerrit.openafs.org/14006
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

3 years agovos: Add missing -partition requires -server checks 05/14005/7
Michael Meffie [Mon, 23 Dec 2019 23:37:21 +0000]
vos: Add missing -partition requires -server checks

The `vos remove` command was missing a check for the -server option when
the -partition option is given. This command requires the -server option
when the -partition is given, as documented in the man page.

The `vos syncvldb` command performed the check for the -server option
when the -partition option is given, but in the wrong location.

As documented, the `vos unlockvldb` command permits the -partition
option without a -server option, in which case all of the volumes listed
in the VLDB with sites on the specified partition are unlocked.
However, this command incorrectly issued an RPC to a volume server at
address 0.0.0.0 when only the partition is given.

Change-Id: I6b878678e28b34250e63d2d082747f6fd416972d
Reviewed-on: https://gerrit.openafs.org/14005
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

3 years agovos: avoid double release of a volume lock 26/14426/2
Mark Vitale [Thu, 5 Nov 2020 23:16:51 +0000]
vos: avoid double release of a volume lock

To update a volume entry in the VLDB, vos commands typically lock the
volume entry via VL_SetLock, then call VL_UpdateEntryN, then release the
lock via VL_ReleaseLock.  However, some vos commands exploit the
optional lock release flags of VL_UpdateEntryN to combine the update and
unlock operations into a single RPC.  This approach requires extra care
to ensure that VL_ReleaseLock is issued for a failed VL_UpdateEntryN,
but NOT for a successful VL_UpdateEntryN.

Unfortunately, the following commands have success paths that fall
through to the error path, resulting in a double release of the volume
lock:
 - vos convertROtoRW
 - vos release

A second VL_ReleaseLock of a volume entry that has already been unlocked
via VL_UpdateEntryN is essentially a harmless no-op (other than negating
any benefit of exploiting the VL_UpdateEntryN lock flags).  However, if
there is a race with another volume operation on the same volume, it is
possible for this bug to release the volume lock of a different volume
operation.

This problem has been present in 'vos release' since OpenAFS 1.0.  This
problem has been present in 'vos convertROtoRW' since the command's
introduction in commit 8af8241e94284522feb77d75aee8ea3deb73f3cc
vol-ro-to-rw-tool-20030314.

Properly maintain state to avoid unlocking a volume (with
VL_ReleaseLock) that has already been unlocked (via VL_UpdateEntryN).

Thanks to Andrew Deason for discovering the issue and suggesting the
fix.

Change-Id: I757b4619b9431d1ca980f755349806993add14a5
Reviewed-on: https://gerrit.openafs.org/14426
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovolser: document 'vos restore -readonly' restriction 48/14348/4
Mark Vitale [Fri, 28 Aug 2020 20:19:29 +0000]
volser: document 'vos restore -readonly' restriction

Commit 0c03f8607e15 vos-command-enhancements-20011008 introduced the
'vos restore' -readonly option, which allows the restored volume to be
RO instead of the default RW.  The commit message documents the
following restriction:

- ... This option causes the restored volume to be an RO volume.  It is
  not permitted to restore an RO volume when the associated RW volume
  already exists.  While it is possible to restore an RW volume where an
  RO volume exists, caution should be used to avoid doing this with VLDB
  entries created by 'vos restore -readonly', since such entries have
  their ROVOL and RWVOL ID's set to the same thing.

Document this restriction in the 'vos restore' man page, and in a code
comment.

No functional change is incurred by this commit.

Change-Id: I34f6c5434b82da538a38a9d219207b33dcf62b17
Reviewed-on: https://gerrit.openafs.org/14348
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovolser: improve error checking for 'vos restore' 47/14347/4
Mark Vitale [Fri, 28 Aug 2020 19:42:06 +0000]
volser: improve error checking for 'vos restore'

UV_RestoreVolume2 calls VLDB_GetEntryByName to obtain information for
sanity checking, but only checks for a VL_NOENT error code; other codes
are thus ignored, which may lead to confusing results.

Add an additional error check for 'vos restore' (and other callers of
UV_RestoreVolume2) to stop and issue an error message if a non-VL_NOENT
error code is received from VLDB_GetEntryByName.

Change-Id: Idf41965fdd84fa282a3397215ec393ae10f72018
Reviewed-on: https://gerrit.openafs.org/14347
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovolser: fix 'cant' typos 46/14346/4
Mark Vitale [Mon, 31 Aug 2020 18:30:26 +0000]
volser: fix 'cant' typos

Correctly spell "can't" in a log message and a comment.

Change-Id: I9d5c667d9c5ea3c5b726f958431c497353433239
Reviewed-on: https://gerrit.openafs.org/14346
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: avoid panic in DNew when afs_WriteDCache fails 04/13804/13
Mark Vitale [Fri, 19 Jul 2019 18:41:55 +0000]
afs: avoid panic in DNew when afs_WriteDCache fails

afs_WriteDCache may fail for an IO error, or if interrupted (EINTR).
Unfortunately, DNew will panic in this case, crashing the entire
machine.

In order to avoid an outage in this case, don't panic.  Instead, reflect
the error back to the caller of DNew.

While here, add Doxygen comments to DNew.

Change-Id: I27a8f89bab979c5691dded70e8b9eacbe8aff4fd
Reviewed-on: https://gerrit.openafs.org/13804
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoafs: remove redundant assignment 02/13802/13
Mark Vitale [Mon, 19 Aug 2019 19:43:09 +0000]
afs: remove redundant assignment

DRelease has two assignments for tp = entry->buffer; remove the second
(redundant) one.

Introduced with 0284e65f97861e888d95576f22a93cd681813c39 'dir: Explicitly
state buffer locations for data'.

No functional change should be incurred by this commit.

Change-Id: If4a17862f451973075fa3fa267b5139046d97ede
Reviewed-on: https://gerrit.openafs.org/13802
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: check DNew return code 01/13801/14
Mark Vitale [Wed, 5 Feb 2020 22:49:03 +0000]
dir: check DNew return code

Commit 0284e65f97861e888d95576f22a93cd681813c39 'dir: Explicitly state
buffer locations for data' changed DNew and DRead to return a return
code.  However, the callers of DNew were not modified to check the new
return code.  (This commit applied only to the implementations dealing
with AFS directories, in afs/afs_buffer.c and dir/dir.c.  The ubik
implmentations of DNew and DRead, dealing with ubik databases, were not
modified.)

Modify all (non-ubik) callers of DNew to check the return code.  In
addition, modify code as needed so return codes are properly propagated
to the callers.

While here, add Doxygen comments for AddPage and FindBlobs.

Change-Id: Iabde6499745dd351f3fcda73c9f52c440a36490e
Reviewed-on: https://gerrit.openafs.org/13801
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoRemove unused xdr types 04/14404/4
Andrew Deason [Mon, 19 Oct 2020 23:30:27 +0000]
Remove unused xdr types

Numerous types and constants are defined in our various RPC-L files
that are never used or referenced by anything. Remove them.

Change-Id: I0b03be1ce0e186a88f80d2f3f7a66a1e25965ff3
Reviewed-on: https://gerrit.openafs.org/14404
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovolser: apply static keyword to VolPartitionInfo definition 21/13321/3
Benjamin Kaduk [Sun, 2 Sep 2018 22:10:56 +0000]
volser: apply static keyword to VolPartitionInfo definition

The function declaration was already marked as static; mark the
definition as well for consistency (and consistency with the other
helpers in this file).

Change-Id: I642db1d27efd34ab2a09f7299791c19d07b1f923
Reviewed-on: https://gerrit.openafs.org/13321
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: check afs_dir_Create return code in afs_dir_MakeDir 00/13800/13
Mark Vitale [Mon, 4 Mar 2019 01:20:58 +0000]
dir: check afs_dir_Create return code in afs_dir_MakeDir

afs_dir_MakeDir() ignores the return code from afs_dir_Create() for the
'.' and '..' ("dot" and "dotdot") directories.  This has been the case
from the earliest implementation (MakeDir() calling Create()) in the
original IBM import.

Instead, check the return codes to prevent the possibility of creating
malformed directories.

Change-Id: I60179488429dfa9afe60c4862c5e42b41f1e0048
Reviewed-on: https://gerrit.openafs.org/13800
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoptserver: rename NameToID and IDToName helpers 20/13320/3
Benjamin Kaduk [Sun, 2 Sep 2018 22:06:38 +0000]
ptserver: rename NameToID and IDToName helpers

These helper function names alias the names of public RPCs and can
cause confusion when grepping the code.  Rename them in a different
style to provide greater hamming distance between the various
functions involved in handling these RPCs.

Change-Id: I0e2c7997bc145888affdac28716293ff820756c7
Reviewed-on: https://gerrit.openafs.org/13320
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agodir: check afs_dir_MakeDir return code in DirSalvage 99/13799/10
Mark Vitale [Mon, 4 Mar 2019 01:51:45 +0000]
dir: check afs_dir_MakeDir return code in DirSalvage

Since the original IBM import, DirSalvage() has ignored the return code
from afs_dir_MakeDir() (f.k.a. MakeDir).  This has been safe because, as
the comment states, afs_dir_MakeDir returns no (non-zero) error code.

In preparation for a future commit, add a check for the return from
afs_dir_MakeDir and remove the comment.

Change-Id: Ibb259a7aaeeb21ef70a7794143a0dadb2a75725d
Reviewed-on: https://gerrit.openafs.org/13799
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: distinguish logical and physical errors on reads 98/13798/10
Mark Vitale [Thu, 30 Jan 2020 19:04:05 +0000]
dir: distinguish logical and physical errors on reads

The directory package (src/dir) salvage routines DirOK and DirSalvage
check a global variable 'DErrno' to distinguish logical errors (e.g.
short read) from physical errors (e.g. EIO).  However, since the
original IBM import, this logic has not worked correctly because there
is no longer any code that sets the value of DErrno - its value is
always zero.

Instead, modify all implementations of ReallyRead to optionally return
the errno for low-level IO errors.

Also, create a new userspace-only variant - DReadWithErrno() - of the
src/dir/buffer.c version of DRead (the version called by DirOK and
DirSalvage, and the only caller of ReallyRead) to return the ReallyRead
errno upon request.

Also create an analogous variant of afs_dir_GetBlobs,
afs_dir_GetBlobsWithErrno().

Finally, convert DirOK and DirSalvage to use the new variants and
replace DErrno with equivalent logic.  Remove all other references to
DErrno.

Change-Id: I3de182ce49c1682572142da594af5dc2c00ede74
Reviewed-on: https://gerrit.openafs.org/13798
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: Log pid with disk cache read errors 16/14416/2
Andrew Deason [Mon, 26 Oct 2020 17:19:19 +0000]
afs: Log pid with disk cache read errors

Log the current pid (and procname) when we complain about an error
when reading from CacheItems in afs_UFSGetDSlot. These errors can
result in confusing situations, so it can be helpful to know at least
what process saw the error.

Our logic for logging this information is getting a bit large, so also
move this to a new function, LogCacheError.

Change-Id: I3427e736458784df0d516f4182684605e930e128
Reviewed-on: https://gerrit.openafs.org/14416
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoroken: use strtok_r from roken 91/13891/14
Cheyenne Wills [Tue, 8 Oct 2019 17:54:58 +0000]
roken: use strtok_r from roken

Windows standard library doesn't provide strtok_r.  Use the strtok_r
that is provided from roken.

Change-Id: I1bccb9a306c9dd1963f044127fb5dfe4da5728cc
Reviewed-on: https://gerrit.openafs.org/13891
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoImport of code from heimdal 90/13890/14
Heimdal Developers [Tue, 8 Oct 2019 16:47:05 +0000]
Import of code from heimdal

This commit updates the code imported from heimdal to
5dfaa0d10b8320293e85387778adcdd043dfc1fe (git2svn-syncpoint-master-311-g5dfaa0d10)

New files are:
roken/strtok_r.c

Change-Id: I27042f614c7d6ce9a95a80d01474e8bf401e4760
Reviewed-on: https://gerrit.openafs.org/13890
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoroken: add strtok_r to the imported file list 89/13889/14
Cheyenne Wills [Tue, 8 Oct 2019 17:02:59 +0000]
roken: add strtok_r to the imported file list

Import the strtok_r function which is needed by audit for parsing
command line options.

Change-Id: I8412c5a663dc3315c4146665edb72d9a6b8df5be
Reviewed-on: https://gerrit.openafs.org/13889
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoDetect realloc failure 13/13313/3
Benjamin Kaduk [Sun, 2 Sep 2018 02:47:39 +0000]
Detect realloc failure

While reviewing other commits, a call to realloc() was discovered that
would leak memory on failure (by virtue of always assigning the realloc()
return value to the pointer holding the input address, even when the
return value is NULL).  Check for failure and return early in that case
(giving an incomplete list of events).

Change-Id: Ic6e889f1d990bd289812ce4bf8e9cd4ebce488ec
Reviewed-on: https://gerrit.openafs.org/13313
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoptserver: move IDToName, NameToID to ptprocs.c and make static 19/13319/3
Benjamin Kaduk [Sun, 2 Sep 2018 22:03:38 +0000]
ptserver: move IDToName, NameToID to ptprocs.c and make static

These two helpers are only used in implementing server-side RPC handlers,
and having to track the codeflow across files is unhelpful.  Move them
into the file where they're used, make them static, and remove the
prototypes from ptrototypes.h (which is not an installed header, so
there is no API/ABI breakage).

Change-Id: I236d17865a296933f41aaee206535d341c3a955d
Reviewed-on: https://gerrit.openafs.org/13319
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoAssign explicit opcodes to butc RPCs 17/13317/2
Benjamin Kaduk [Sun, 2 Sep 2018 21:35:42 +0000]
Assign explicit opcodes to butc RPCs

This should prevent inadvertent reassignment if additional RPCs
are introduced in the future.

Change-Id: I5645ca478d2ecef9962f4bde04ab8f9895dd9497
Reviewed-on: https://gerrit.openafs.org/13317
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovlserver: Return VL_DBBAD on unhash failure 84/13384/4
Andrew Deason [Mon, 12 Nov 2018 21:06:09 +0000]
vlserver: Return VL_DBBAD on unhash failure

If we try to delete a vlentry, and the vlentry cannot be found on one
of its hash chains, we cannot unhash the vlentry properly and the
operation fails with VL_NOENT. This results in the following error
messages to the user:

        $ vos delentry 123456
        Could not delete entry for volume 123456
        You must specify a RW volume name or ID (the entire VLDB entry will be deleted)
        VLDB: no such entry
        Deleted 0 VLDB entries

This is confusing, because VL_NOENT can also occur if the user
specifies a volume that does actually not exist. This situation is
indicative of database corruption, usually because of a ubik
transaction that was only half-applied, or because of other ubik bugs
in the past.

The situation can only really be fixed by repairing the database, so
return VL_DBBAD in this case instead, to more clearly indicate that
something is wrong with the database, and not a problem with the
arguments the caller provided.

Change-Id: I6fc275c3ad05c108778f36687227b0a927cca5da
Reviewed-on: https://gerrit.openafs.org/13384
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovlserver: Add VL_DBBAD error code 83/13383/4
Andrew Deason [Mon, 12 Nov 2018 20:41:44 +0000]
vlserver: Add VL_DBBAD error code

The VL_ error table currently doesn't have an error code to indicate
that an operation cannot succeed because the database is corrupted.
There are a few error codes for specific cases of errors that are
probably the result of corruption (like VL_IDALREADYHASHED, or
VL_EMPTY), but these are only for specific cases and indicate rather
low-level internal problems.

There are some instances where the real problem preventing an
operation from succeeding is that the database is just corrupt or
inconsistent in some way, and the administrator must repair the
database before it can succeed. And we currently don't have any way of
indicating that situation via an error code.

So, introduce the VL_DBBAD code, to indicate this situation. Error
codes already exist in other tables for similar situations, such as
PRDBBAD, and KADATABASEINCONSISTENT.

This commit does not use the new error code anywhere; we just
introduce it into the VL_ error table, so comerr-using applications
will be able to interpret it.

Note that the VL_DBBAD error code has been recognized by the AFS
Assigned Numbers Registry as recorded in the ticket history of
<https://rt.central.org/rt/Ticket/Display.html?id=134817>

Change-Id: I8fea356a4e0db907ec8418efe6ef35d547be0a63
Reviewed-on: https://gerrit.openafs.org/13383
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoptserver: move allocation out of put_prentries() into listEntries() 15/13315/3
Benjamin Kaduk [Thu, 30 Aug 2018 14:54:23 +0000]
ptserver: move allocation out of put_prentries() into listEntries()

put_prentries() is a helper function for listEntries(), but the contract
between the two is rather odd -- put_prentries() is expected to notice
when the backing store has not yet been allocated and silently allocate
it, even though there is only the single caller and the allocation could
be done in the caller.

Move the allocation to the caller and adjust the "buffer is full"
logic accordingly, and normalize the initialization of the output
array to just use calloc() instead of individual memset()s when
populating each entry.

Change-Id: Icf84e3b60eae81a1570b12d7adbf006a24a104f3
Reviewed-on: https://gerrit.openafs.org/13315
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovolser: Avoid calling osi_audit before audit init 72/13772/20
Cheyenne Wills [Thu, 6 Jun 2019 20:08:53 +0000]
volser: Avoid calling osi_audit before audit init

volmain.c calls osi_audit before the audit facility is fully
initialized.

Commit 16d67791 (auditlogs-for-everyone-20050702) introduced the
-auditlog parameter; it appears that it didn't remove the call
to osi_audit (right after osi_audit_init) that was called before command
line argument processing. This resulted in calling the audit facility
before it was fulling initialized with the -auditlog and
-audit-interface parameters.  The 16d67791 commit replicated the
osi_audit call after command line processing.

Change-Id: Ia0c0054a2fb11892b5b30c0f0838a4d6bbdf9bbb
Reviewed-on: https://gerrit.openafs.org/13772
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoaudit: Always call pthread_once in osi_audit_init 03/14403/4
Andrew Deason [Mon, 19 Oct 2020 21:07:44 +0000]
audit: Always call pthread_once in osi_audit_init

Currently, we skip the pthread_once call in osi_audit_init if
audit_lock_initialized is set. But this is somewhat pointless, since
pthread_once will effectively do this check itself, and better (it
will wait if osi_audit_init is actively running in another thread).

So just get rid of audit_lock_initialized, and replace the other
assert for audit_lock_initialized with another plain pthread_once
call.

Change-Id: I466c8ec2d1516edecaae23d4354892e7e3a88918
Reviewed-on: https://gerrit.openafs.org/14403
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoremove unused src/butc/common.h 22/13322/2
Benjamin Kaduk [Thu, 6 Sep 2018 23:51:06 +0000]
remove unused src/butc/common.h

Change-Id: Ie25a9ca4f715c841a7f7fa130176cfbdc5ef18e7
Reviewed-on: https://gerrit.openafs.org/13322
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobutc: consistently spell taskId parameter 18/13318/2
Benjamin Kaduk [Sun, 2 Sep 2018 21:37:44 +0000]
butc: consistently spell taskId parameter

All but one RPC used the capitalization "taskId"; adjust the long
straggler for consistent style.

Change-Id: I996d96a4fc67af7f745bf67041c90390073ca9ea
Reviewed-on: https://gerrit.openafs.org/13318
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoRemove commented-out butc RPC definitions 16/13316/2
Benjamin Kaduk [Sun, 2 Sep 2018 21:18:31 +0000]
Remove commented-out butc RPC definitions

These functions have been commented out since the original IBM
import, and un-commenting them in their current location would
be an ABI break (by causing opcodes to be reassigned for subsequent
RPCs).  Since they are just noise in the interface description
file, remove them.

Change-Id: I7e8cd2e7dfa4469e39e26a0437059c108f3ef218
Reviewed-on: https://gerrit.openafs.org/13316
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobutc: Initialize RPC outputs at top of function 14/13314/2
Benjamin Kaduk [Sun, 9 Sep 2018 02:25:40 +0000]
butc: Initialize RPC outputs at top of function

RPC handlers are a little bit special in that their output parameters
are discarded on error and an Rx abort is sent instead of the usual
response fields.  Nonetheless, it is good code hygeine to adhere to
the practices we use for the rest of the functions in the tree:
initialize output variables before the first return.

Change-Id: I6c2e25b04ccb6277bd28e398121723b92fe42b04
Reviewed-on: https://gerrit.openafs.org/13314
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovlserver: Warn when we cannot unhash deleted entry 82/13382/3
Andrew Deason [Mon, 12 Nov 2018 21:01:18 +0000]
vlserver: Warn when we cannot unhash deleted entry

If we are trying to delete an entry from the vldb, we fail with
VL_NOENT if we cannot find the given entry on one of its hash chains.
This is indicative of corruption in the vldb (since we have an entry
not on a hash chain), but we don't really indicate this clearly. There
are no log messages, and the user running 'vos' only sees an error
like this:

    $ vos delentry 123456
    Could not delete entry for volume 123456
    You must specify a RW volume name or ID (the entire VLDB entry will be deleted)
    VLDB: no such entry
    Deleted 0 VLDB entries

Which is the exact same error message if the user tries to delete a
volume that does not actually exist.

We currently do not have an error code that clearly says that the
database appears corrupted and needs to be fixed, but we can at least
log an error in VLLog for this case, to give the administrator a
chance at fixing the situation. So, log a message in this situation.

Change-Id: I4f0ee8749a90441e1f8d779890293dc5d1d9dbee
Reviewed-on: https://gerrit.openafs.org/13382
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobos: do not assume fs just if dafs bnode is stopped 82/14382/2
Mark Vitale [Tue, 6 Oct 2020 04:02:53 +0000]
bos: do not assume fs just if dafs bnode is stopped

If dafs is configured but stopped, 'bos salvage <fs> <vicep>
-forceDAFS' will fail with:

  bos: failed to get instance info for 'fs' (no such entity)
  bos: shutting down 'fs'.
  bos: can't stop 'fs' (no such entity)

This is due to incomplete logic in IsDAFS, introduced with commit
e46f10a0a0a930f318833a8a86b10c19744160c1 'bos: Do not assume DAFS just
if DAFS bnode exists'

Add logic to IsDAFS to work correctly when dafs is configured but
stopped.

Change-Id: I50f8209180536d25e68c0ad6fb826202d8f27ce7
Reviewed-on: https://gerrit.openafs.org/14382
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: defer audit open until log dir is created and current 81/14381/4
Mark Vitale [Tue, 6 Oct 2020 14:18:11 +0000]
bozo: defer audit open until log dir is created and current

On a new OpenAFS install where the log directory has not yet been
created. 'bosserver -auditlog /usr/afs/logs/<auditlog>' (absolute path)
fails with ENOENT because the log directory doesn't exist yet.

Furthermore, 'bosserver -auditlog <auditlog>' (relative path) succeeds,
but the audit file is created in the current working directory when
bosserver was started, not in the expected log directory (Transarc
/usr/afs/logs).

Both problems have been present since bosserver audit log support was
introduced by commit 16d67791dce45e5d4ee9b854c796492ffcde2113
'auditlogs-for-everyone-20050702'.

Reorder the bosserver initialization steps to ensure that the log
directory has been created and is the current working directory, before
creating and opening the audit log.

Change-Id: I1dc3c136edd12c5425ef0b7a3212a18d4c3036f7
Reviewed-on: https://gerrit.openafs.org/14381
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: Properly detect presence of -auditlog 02/14402/3
Andrew Deason [Sun, 18 Oct 2020 01:51:51 +0000]
bozo: Properly detect presence of -auditlog

cmd_OptionAsString returns non-zero if the given option _isn't_ given
(CMD_MISSING), so we need to call osi_audit_file only when
cmd_OptionAsString returns 0. Since commit
f6cdf71 (bozo: Use libcmd for command line options), this causes
bosserver to complain on startup if no -auditlog was given:

    $ bosserver
    Warning: auditlog (null) not writable, ignored.

To fix this, skip calling osi_audit_file if -auditlog was not given.

While we're changing this anyway, change our processing of our
audit-related options to more closely match what other daemons do,
like ptserver or viced, so it's easier to see if we're doing the right
thing. That is, just call cmd_OptionAsString() without a conditional,
and just test if auditFileName is non-NULL later on, after options
processing.

Change-Id: I563c7efd02cb5210c32c0cc7f5a03683db792e98
Reviewed-on: https://gerrit.openafs.org/14402
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: prevent double release of global lock afs_xvcb 11/14411/2
Mark Vitale [Fri, 28 Oct 2016 22:12:19 +0000]
afs: prevent double release of global lock afs_xvcb

afs_GetServer calls ReleaseWriteLock(&afs_xvcb) twice within a few
lines.  The second one is spurious.

Commits b18653de7ae90491c2e75f4a98410581655d776c 'xserver lock order
violation' and f2bf60ed4f1323cd6f74f2f01114f7e4f714db53 'xvcb lock order
violation' were written by the same author at the same time and
apparently were victims of a bad merge.

Discovered during a lock audit project as a panic during afsd startup:

  assertion failed: (&afs_xvcb)->excl_locked == WRITE_LOCK, file:
  /home/mvitale/src/sna-openafs/src/afs/afs_server.c, line: 2089

afs_GetServer is called frequently by many threads and so this bug could
easily have released another thread's write lock on afs_xvcb.

Remove the spurious second release.

Change-Id: I495f4775e18ed37cfbccd03b5f25594586864b83
Reviewed-on: https://gerrit.openafs.org/14411
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoubik: Introduce IndexOf() 60/14060/7
Marcio Barbosa [Fri, 28 Feb 2020 02:41:53 +0000]
ubik: Introduce IndexOf()

To make the ubik_Call* functions cleaner, consolidate code that finds
the index of the connection associated with a host into a new function.

No functional change should be incurred by this commit.

Change-Id: I320d7a41221cb533e8d077c412f872152ac43b75
Reviewed-on: https://gerrit.openafs.org/14060
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: Handle osi_NewVnode failures 01/13701/8
Andrew Deason [Thu, 18 Jul 2019 21:21:10 +0000]
afs: Handle osi_NewVnode failures

Currently, code inside afs_vcache.c assumes that osi_NewVnode always
returns non-NULL, which means that osi_NewVnode must panic if it
cannot create a new vnode.

All of the callers of afs_GetVCache, afs_NewVCache, etc, already
handle getting a NULL return, though (after all, the given fid may not
exist or be inaccessible due to network errors, etc). So, just
propagate NULL returns from osi_NewVnode up to our callers, to avoid
panics in these situations.

Modify osi_NewVnode on many arches to return an error on allocation
failure, instead of panic'ing.

Change-Id: Ib578b1747590bdf65327d4674e0849811ed999eb
Reviewed-on: https://gerrit.openafs.org/13701
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agostats: incorrect clock square algorithm 76/14376/2
Mark Vitale [Mon, 18 Sep 2017 23:45:10 +0000]
stats: incorrect clock square algorithm

Since the original IBM code import, OpenAFS has an algorithm for
squaring clock values, implemented identically in three different
places.  This algorithm does not account correctly for microsecs
overflow into seconds, resulting in incorrect "sum-of-squares" values
for queue and execution time in several OpenAFS performance utilities.

Specifically, this code:

        t1.tv_usec += (2 * t2.tv_sec * t2.tv_usec) % 1000000                   \
                      + (t2.tv_usec / 1000)*(t2.tv_usec / 1000)                \
                      + 2 * (t2.tv_usec / 1000) * (t2.tv_usec % 1000) / 1000   \
                      + (((t2.tv_usec % 1000) > 707) ? 1 : 0);                 \

Can allow for the tv_usec field to be increased by a theoretical max
of around:

        t1.tv_usec += 999998                                                   \
                      + 999*999                                                \
                      + 2 * 999 * 999 / 1000                                   \
                      + 1;                                                     \

Or:

        t1.tv_usec += 1999996;                                                 \

If t1.tv_usec is already 999999, after this calculation its value
could be as high as 2999995. So just checking once if t1.tv_usec is
over 1000000 is not sufficient, since the resulting value (1999995) is
still over 1000000.

Correct all implementations by repeatedly checking if tv_usec is over
1000000 after the above calculation:

macro                   affected utility
=====================   ============================
afs_stats_SquareAddTo   xstat_cm_test
fs_stats_SquareAddTo    xstat_fs_test
clock_AddSq             rxstat_get_process and _peer

Change-Id: I3145d592ba6bc1556729eac657f43d476c99eede
Reviewed-on: https://gerrit.openafs.org/14376
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorxstats: correctly report vlserver VL_* RPC stats 75/14375/3
Mark Vitale [Mon, 28 Sep 2020 20:35:38 +0000]
rxstats: correctly report vlserver VL_* RPC stats

Since the original IBM code import, rxstat_get_process and
rxstat_get_peer have reported vlserver VL_* RPC stats as for the
"volserver interface".

Correct this to read "vlserver interface".

Change-Id: Ie65fd41150bed8180ad8792c21a67012084459ab
Reviewed-on: https://gerrit.openafs.org/14375
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorxstats: correctly distinguish client and server stats 74/14374/3
Mark Vitale [Mon, 28 Sep 2020 19:40:34 +0000]
rxstats: correctly distinguish client and server stats

Commit d3eaa39da3693bba708fa2fa951568009e929550 'rx: Make the rx_call
structure private' inadvertently caused all rxstats (aka rpcstats) to be
recorded as client stats by hardcoding the value for isServer to 1.

Therefore, when peer or process rxstats are enabled for a OpenAFS
component, the rxstat_get_process and rxstat_get_peer utilities will
erroneously report both client and server stats as "accessed as a client".

This is particularly problematic for ubik VOTE_* and DISK_* RPC stats,
for which a given ubik server may be both client and server over time.
In this case, both client and server stats are conflated into the same
"accessed as a client" counters.

Instead, properly pass the value of isServer from
rx_RecordCallStatistics through to rxi_IncrementTimeAndCount.

Note to maintainers:
This bug is only in master and all 1.8.x releases; no 1.6.x releases are
affected.

Note:
Confusingly, isServer=1 indicates client stats and isServer=0 indicates
server stats.  However, this is a quirk of the original implementation
and wire format of the RXSTATS_* RPCs and cannot be changed.  isServer
is actually shorthand for "remote is server"; thus all RPC client stubs
record their rxstats with isServer == 1, and all RPC server stubs record
their rxstats with isServer == 0.

Change-Id: I2420f807e2c18ddfb9de7093a487825fa2d0a68e
Reviewed-on: https://gerrit.openafs.org/14374
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovolser: Close dirp on error in ConvertROtoRW 42/14342/3
Marcio Barbosa [Thu, 3 Sep 2020 20:11:34 +0000]
volser: Close dirp on error in ConvertROtoRW

Currently, if SAFSVolConvertROtoRWvolume cannot create a new transaction
for the volume to be converted, it returns without closing the directory
stream opened by it. To prevent this leak, go through a new 'goto done'
destructor if NewTrans fails.

Change-Id: Ie0580e7739ae667f1cd2f9cabb8aaf5e15d3f2dd
Reviewed-on: https://gerrit.openafs.org/14342
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: Log each dir and file with bad access rights 30/14330/2
Michael Meffie [Fri, 28 Aug 2020 15:24:10 +0000]
bozo: Log each dir and file with bad access rights

The bosserver directory and file access check stops after finding one
directory or file with incorrect permissions or owner. A log message is
written for this first one found, but more than one directory or file
may have incorrect access rights.

Instead check all of them so the bosserver logs a warning message for
each incorrect director or file permission found.  This should make it
easier to fix all of the file permission problems at once.

Change-Id: Ia3f14800ce036aa390929109a286cf21828e8a35
Reviewed-on: https://gerrit.openafs.org/14330
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: Add KeyFileExt and rxkad.keytab to access rights check 29/14329/3
Michael Meffie [Fri, 28 Aug 2020 15:23:00 +0000]
bozo: Add KeyFileExt and rxkad.keytab to access rights check

When the KeyFileExt and rxkad.keytab were added to OpenAFS, they were
not added to the bosserver's access rights check. Add these files to the
bosserver access checks, with the same access rights needed for the
original KeyFile.

Also, add the full path for KeyFileExt to the dirpath package (not just
the filename), which was not done when the KeyFileExt was introduced.
This is needed to perform the access checks.

Change-Id: I8c9028e846fad9f15823baeb7cc15a8f80ed5c1c
Reviewed-on: https://gerrit.openafs.org/14329
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: remove vestigial externs for afs_xvcache 06/14406/2
Mark Vitale [Wed, 23 Sep 2020 21:32:40 +0000]
afs: remove vestigial externs for afs_xvcache

These have not been needed since src/afs/afs_prototypes.h gained 'extern
afs_rwlock_t afs_xvcache' with commit
8f2df21ffe59e9aa66219bf24656775b584c122d
"pull-prototypes-to-head-20020821"

Remove the vestigial extern references.

Change-Id: Id6aceff0d5df1f1bed210a3fbf2951c62f35ddbb
Reviewed-on: https://gerrit.openafs.org/14406
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: remove vestigial externs for afs_xcbhash 05/14405/2
Mark Vitale [Wed, 23 Sep 2020 21:02:52 +0000]
afs: remove vestigial externs for afs_xcbhash

Commit 64cc7f0ca7a44bb214396c829268a541ab286c69 "afs: Create
afs_StaleVCache" consolidated many references to afs_xcbhash into a new
function afs_StaleVCache.  However, this left many references to 'extern
afs_wrlock_t afs_xcbhash' that are no longer needed.

But actually, many of these have not been needed since
src/afs/afs_prototypes.h gained 'extern afs_rwlock_t afs_xcbhash' with
commit 8f2df21ffe59e9aa66219bf24656775b584c122d
"pull-prototypes-to-head-20020821"

Remove the vestigial extern references.

No functional change is incurred by this commit.

Change-Id: Ie6cfb6d90c52951795378d3b42e041567d207305
Reviewed-on: https://gerrit.openafs.org/14405
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoxstat: prevent CPU loop when -period 0 66/14366/4
Mark Vitale [Fri, 18 Sep 2020 16:46:57 +0000]
xstat: prevent CPU loop when -period 0

Historically xstat_cm_test and xstat_fs_test have supported option
'-period <mm>' to specify continuous operaiton for a length of time.  If
'-period 0' was specified, both programs exited immediately.

Beginning with commits 2c1a7e47336c8f8d14dd6c65d53925a9e0e87c66 'xstat:
add xstat_*_Wait functions' and 6b67cac432043a43d7cdfa6af972ab54412aff94
'convert xstat and friends to pthreads', xstat_cm_test and xstat_fs_test
now support -period 0 to run "forever".  This support is implemented in
xstat_cm_Wait and xstat_fs_Wait, respectively.  Although the "wait
forever" logic was added to allow consolidation of similar code in
afsmonitor, it also changed how xstat_cm_test and xstat_fs_test behave
for '-period 0'.

Unfortunately, there is a bug in this support, at least when running on
pthreads.  After the initial 24 minute timer expires, the while (1) will
repeatedly run select with a timeout that is now 0.  This causes the
while loop to consume 100% of the CPU on which this thread is
dispatched.

Instead, modify the wait-forever logic to specify NULL for the select()
timeout value.  Also update the man page to document that '-period 0'
means forever.

Change-Id: I25d0d5be0eedb8bf3de495785b9b03a3e3d45221
Reviewed-on: https://gerrit.openafs.org/14366
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: Return to userspace after AFS_NEW_BKG reqs 84/13984/4
Andrew Deason [Fri, 13 Dec 2019 03:00:20 +0000]
afs: Return to userspace after AFS_NEW_BKG reqs

Currently, for AFS_NEW_BKG, background daemons run in the context of a
normal user process (afsd), in order to return to run
userspace-handled background ops. For non-AFS_NEW_BKG when
AFS_DAEMONOP_ENV is defined, background daemons run as kernel threads
instead, and have no corresponding userspace process.

On LINUX, whether or not we run as a kernel thread has some odd
side-effects: at least one example of this is how open file handles
(struct file) are treated when closed. When the last reference to a
struct file is closed, the final free is deferred to an asynchronous
call to be executed "later", in order to avoid issues with lock
inversion. For kernel threads, "later" means the work is schedule on
the global system work queue (schedule_work()), but for userspace
processes, it is scheduled on the task work queue (task_work_add()),
which is run around when the thread returns to userspace. For
background daemons, we never return from the relevant syscall until we
get a userspace background request (or the client is shutting down),

Commit ca472e66 (LINUX: Turn on AFS_NEW_BKG) changed LINUX to use
AFS_NEW_BKG background daemons, so background requests now run as a
normal userspace process, and last-reference file closes are deferred.
Since we may never return to userspace, this means that our file
handles (used for accessing the disk cache) may never get freed,
leading to an unbounded number of file handles remaining open.

This can be seen by seeing the first value in /proc/sys/fs/file-nr
growing without bound (possibly slowly), as accessing /afs causes
background requests. Eventually the number of open files can exceed
the /proc/sys/fs/file-max limit, causing further file opens to fail,
causing various other problems and potentially panics.

To avoid this issue, define a new userspace background op, called
AFS_USPC_NOOP, which gets returned to the afsd background daemon
process. When afsd sees this, it just does nothing and calls the
AFSOP_BKG_HANDLER syscall again, to go into the background daemon loop
again. In afs_BackgroundDaemon, we return the AFS_USPC_NOOP op
whenever there are no pending background requests, or if we've run 100
background requests in a row without a break. This causes us to return
to userspace periodically, preventing any such task-queued work from
building up indefinitely.

Do this for all platforms (currently just LINUX and DARWIN), in order
to simplify the code, and possibly avoid other similar issues, since
staying inside a syscall for so long while doing real work is arguably
weird.

Add a documentation comment block for afs_BackgroundDaemon while we're
here.

Thanks to mvitale@sinenomine.net for discovering the file leak.

Change-Id: I1953d73b2142d4128b064f8c5f95a5858d7df131
Reviewed-on: https://gerrit.openafs.org/13984
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoubik: Remove unused sampleName 86/14386/2
Andrew Deason [Wed, 14 Oct 2020 01:18:59 +0000]
ubik: Remove unused sampleName

The RPC-L type sampleName and related constant UMAXNAMELEN are not
referenced by anything, and have been unused since OpenAFS 1.0. Remove
the unused definitions.

Change-Id: I21a11d9db9ed80547de8685623fb09f9a86934f1
Reviewed-on: https://gerrit.openafs.org/14386
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agodir: Set srcdir correctly in src/dir/test 84/14384/2
Andrew Deason [Tue, 13 Oct 2020 17:17:37 +0000]
dir: Set srcdir correctly in src/dir/test

srcdir is a magic variable that needs to be set to @srcdir@, not some
relative path like ../../.. (which will usually be somewhere in the
objdir, not srcdir). Set it correctly in here.

Without this, objdir builds can fail with:

    make[4]: Entering directory '...obj/src/dir/test'
    make[4]: *** No rule to make target 'dtest.o', needed by 'dtest'.  Stop.

Which happens because the automatic rule for dtest.o can't be
constructed, since we cannot find dtest.c automatically because srcdir
isn't set properly.

This has been broken since commit 37b4195d (dtest-20021111), but was
not noticeable until commit 192a2ff4 (dir: make dtest buildable
again), since that caused dtest to actually get built.

Also set LIBS correctly in here, using the conventional ${TOP_LIBDIR},
since ${srcdir} no longer points to "../../..".

Change-Id: I539e01a4397c558dc0eda492834b3f9913f71634
Reviewed-on: https://gerrit.openafs.org/14384
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: Use libcmd for command line options 45/13845/16
Cheyenne Wills [Fri, 21 Aug 2020 18:53:30 +0000]
bozo: Use libcmd for command line options

Update bosserver to use libcmd for command line parsing.

Change-Id: Iaa55dc33b72983a48089a7b359260916bea2d1e7
Reviewed-on: https://gerrit.openafs.org/13845
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoafs: refactor directory checking in DRead 03/13803/9
Mark Vitale [Mon, 4 Mar 2019 06:37:53 +0000]
afs: refactor directory checking in DRead

Commit d566c1cf874d15ca02020894ff0af62c4e39e7bb
'dread-do-validation-20041012' modified directory checking (in the
afs_buffer.c implementation of DRead()) to use size information passed
to DRead, rather than obtained from the cache via afs_CFileOpen.

Because this directory checking does not require any information from
the cache buffers or the cache partition, we can make the check right
away, before searching the cache buffers or calling afs_newslot.

To clarify and simplify, move the directory sanity checking logic to the
beginning of DRead.  Remove the afs_newslot cleanup logic which is no
longer needed.

While here, add Doxygen comments for DRead.

Change-Id: I8cea4e885ece64e760271c8194c126250f87104e
Reviewed-on: https://gerrit.openafs.org/13803
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: check afs_dir_MakeDir return code in dtest 97/13797/6
Mark Vitale [Thu, 7 Mar 2019 19:31:49 +0000]
dir: check afs_dir_MakeDir return code in dtest

The dtest test program ignores the return from afs_dir_Makedir.

Fix this so errors may be identified in testing.

While here, also improve the diagnostic message for afs_dir_Create
failures, to make it consistent with the new diagnostic message for
afs_dir_MakeDir failures.

Change-Id: Ib882947e01c864344f17faad8a646b2487793f29
Reviewed-on: https://gerrit.openafs.org/13797
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: dtest should flush on error when creating directories 96/13796/6
Mark Vitale [Wed, 6 Mar 2019 16:27:58 +0000]
dir: dtest should flush on error when creating directories

The dtest -f subcommand (CRTest()) exits immediately if there is an
error while adding files.  This may create an empty, incomplete, or
corrupt directory object on disk because we neglected to call DFlush
before exiting.

Always call DFlush from CRTest() whether it fails or succeeds.

Change-Id: Ia7b4ad00ea6f4f9f788cd75ae726bdadb60ee9c3
Reviewed-on: https://gerrit.openafs.org/13796
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: correct fid type for dtest 95/13795/6
Mark Vitale [Wed, 6 Mar 2019 04:20:10 +0000]
dir: correct fid type for dtest

The dtest utility has had its fid[] arrays defined as 'long' since the
initial IBM import.  Commit 0a98548832472152304410e41306adcc5b91f6a2
'dir: Make test utility build again' converted some - but not all - the
fid arrays to afs_int32.

Allow dtest to operate correctly by converting the rest of the fid
arrays to afs_int32.

Change-Id: I2ebe36272e02cf860577153ab94f3591e1d707e8
Reviewed-on: https://gerrit.openafs.org/13795
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: make dtest buildable again 94/13794/6
Mark Vitale [Wed, 6 Mar 2019 04:11:38 +0000]
dir: make dtest buildable again

Commit 7fe4125fe3435092b75ed29b884d8d3c2d1a2cad 'dir/vol: Die() really
does' overlooked src/dir/test/dtest.c, breaking its build.

Fix the signature of Die() and the makefile so dtest can be built.
In addition, change the Makefile so it is always built.

Change-Id: I18129acbfdaa770987c7f0b8055ff593f776e518
Reviewed-on: https://gerrit.openafs.org/13794
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agodir: remove unused test files 52/14052/5
Mark Vitale [Fri, 4 Oct 2019 18:52:21 +0000]
dir: remove unused test files

Makefile rules for physio.c and test-salvage.c have been commented out
since the original IBM code import, and were removed in commit
37b4195d603630498664fa0975ea5d5c82f9aa4f 'dtest-20021111' to fix dtest.
However, that commit neglected to remove the source files and other
references to them in Makefile.in

Finish the job by removing the files and references to them.

No functional change is incurred by this commit.

Change-Id: I57527be99cd28a481a86b659d1eb3227af9f1c99
Reviewed-on: https://gerrit.openafs.org/14052
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovol: de-orbit test programs 93/13793/6
Mark Vitale [Mon, 4 Mar 2019 03:06:28 +0000]
vol: de-orbit test programs

The updateDirInode and listVicepx utilities are obsolete; they no longer
build, are severely bitrotted, and have been largely replaced by
volscan.

While here, also remove other objects that have not been built by default
since before the original IBM import:
- ILIST ilist.exe
- NAMEI_PROGS nicreate, nincdec, nino, nilist

Remove all of them from the tree.

Change-Id: I8f68ec425cce5e84bcc5f41d598eec23102109de
Reviewed-on: https://gerrit.openafs.org/13793
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoMake OpenAFS 1.9.0 62/14362/2 openafs-devel-1_9_0
Benjamin Kaduk [Fri, 18 Sep 2020 15:56:44 +0000]
Make OpenAFS 1.9.0

Update version strings for the first 1.9.x development release.

Change-Id: I0d0e204ffe8d64d7c0f794f313c0f24ccea12783
Reviewed-on: https://gerrit.openafs.org/14362
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoImport NEWS from OpenAFS 1.8.6 44/14344/4
Benjamin Kaduk [Fri, 4 Sep 2020 15:56:36 +0000]
Import NEWS from OpenAFS 1.8.6

Stay up to date with the stable branch at least until the initial
version of the new release series.

Change-Id: Iefcd9cc039399cd4cbbcc0474c2cabffa7780305
Reviewed-on: https://gerrit.openafs.org/14344
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoUpdate 1.9.0 NEWS for recent changes 43/14343/4
Benjamin Kaduk [Fri, 4 Sep 2020 15:55:19 +0000]
Update 1.9.0 NEWS for recent changes

Add some entries for the commits that landed since the previous update.

Change-Id: I74820ee5a07c3fb539f233b2bd0c30aab262ba74
Reviewed-on: https://gerrit.openafs.org/14343
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>