pnfs: added status flags and ref count to struct pnfs_device

pnfs_device.status remembers whether a given device has been GRANTED/REVOKED

pnfs_device.layout_count tracks the number of layouts using the device, incremented by pnfs_file_device_get() and decremented by pnfs_file_device_put().  when pnfs_file_device_put() takes layout_count to 0, remove and free the device only if it's flagged as REVOKED

because pnfs_file_device_get() modifies pnfs_device.layout_count, we can no longer use a shared lock; changed pnfs_file_device.lock from SRWLOCK to CRITICAL_SECTION, and moved to pnfs_device.lock to document the fact that it's used for pnfs_device.status and pnfs_device.layout_count

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2010-12-01 15:06:22 -05:00
parent 2286f7a1e3
commit e3119c281e
3 changed files with 68 additions and 25 deletions

View file

@ -99,6 +99,13 @@ enum pnfs_layout_status {
PNFS_LAYOUT_NOT_RW = 0x20,
};
enum pnfs_device_status {
/* GETDEVICEINFO was successful */
PNFS_DEVICE_GRANTED = 0x1,
/* a bulk recall or lease expiration led to device invalidation */
PNFS_DEVICE_REVOKED = 0x2,
};
enum pnfs_return_type {
PNFS_RETURN_FILE = 1,
PNFS_RETURN_FSID = 2,
@ -117,6 +124,9 @@ enum pnfs_return_type {
typedef struct __pnfs_device {
unsigned char deviceid[PNFS_DEVICEID_SIZE];
enum pnfs_layout_type type;
enum pnfs_device_status status;
uint32_t layout_count; /* layouts using this device */
CRITICAL_SECTION lock;
} pnfs_device;
typedef struct __pnfs_stripe_indices {
@ -139,8 +149,8 @@ typedef struct __pnfs_file_device {
pnfs_device device;
pnfs_stripe_indices stripes;
pnfs_data_server_list servers;
struct list_entry entry; /* position in nfs41_client.devices */
SRWLOCK lock;
struct pnfs_file_device_list *devices; /* -> nfs41_client.devices */
struct list_entry entry; /* position in devices */
} pnfs_file_device;
@ -290,6 +300,9 @@ enum pnfs_status pnfs_file_device_get(
IN unsigned char *deviceid,
OUT pnfs_file_device **device_out);
void pnfs_file_device_put(
IN pnfs_file_device *device);
enum pnfs_status pnfs_data_server_client(
IN struct __nfs41_root *root,
IN pnfs_data_server *server,