]> git.michaelhowe.org Git - packages/o/openafs.git/commit
ihandle: Fix IH_REALLYCLOSE for positional I/O
authorAndrew Deason <adeason@sinenomine.net>
Wed, 24 Aug 2011 17:48:19 +0000 (12:48 -0500)
committerDerrick Brashear <shadow@dementix.org>
Tue, 13 Sep 2011 17:48:30 +0000 (10:48 -0700)
commitf4dd94edf7384dee912a09354f500d08421f94d4
tree1f09c69d405c4d1b3434ed21f22eae5e6db4d917
parent026d9fb3b74ce49d3cfef47659bb05fc2ec77e51
ihandle: Fix IH_REALLYCLOSE for positional I/O

Currently, ih_fdclose (which is called by IH_REALLYCLOSE), goes
through every FD_HANDLE_OPEN FdHandle_t and closes it. If it finds
handles that are FD_HANDLE_INUSE, it skips those and sets a flag on
the parent IHandle_t. For non-positional I/O, any future opens cannot
use these _INUSE handles, since _INUSE handles cannot be reused, and
the handle will be actually closed when it is FDH_CLOSE'd.

For positional I/O, the situation is different. Multiple threads can
use the same _INUSE FdHandle_t, and so there is nothing currently
stopping a thread from IH_OPEN'ing an ihandle that has been
IH_REALLYCLOSE'd, and getting back an FdHandle_t that existed before
the IH_REALLYCLOSE was issued. This is important, since IH_REALLYCLOSE
is used on files that are deleted, and future IH_OPENs for the same
inode must not use the cached file descriptor. Getting this wrong can
cause data loss, since it can cause us to read from or write to a file
descriptor referring to a deleted file, when we instead should open a
new copy of that file.

To fix this, we create a new FdHandle_t state called
FD_HANDLE_CLOSING, which is set in IH_REALLYCLOSE if we encounter an
FD_HANDLE_INUSE FdHandle_t. In IH_OPEN, we always skip
FD_HANDLE_CLOSING handles, so we can never get back a cached file
descriptor from before an IH_REALLYCLOSE call.

Reviewed-on: http://gerrit.openafs.org/5308
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 597de25969ebdeaafb7390984b5ce2c8782fd557)

Change-Id: I4ac2e4d10ce20f8575b35385e324b637dffd0671
Reviewed-on: http://gerrit.openafs.org/5404
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/vol/ihandle.c
src/vol/ihandle.h