afs: Don't leave DONTUSE/NEWREPSITE servers out of server list
Don't leave servers that are marked VLSF_DONTUSE or VLSF_NEWREPSITE out of the server list for a volume; rather, mark DONTUSE ones excluded and mark either NEWREPSITE excluded if the number of updated servers is <50% of the usable servers or mark !NEWREPSITE excluded otherwise. Mark the server list as a whole with a 3-state flag to indicate whether we think the RW volume is being replicated to the RO volume, and, if so, whether we should switch to using updated replication sites (VLSF_NEWREPSITE) or stick with the old for now. This processing is pushed up from the VLDB RPC reply parser to the code that generates the server list from that information. Doing this allows the old list to be kept with just the exclusion flags replaced and to keep the server records pinned and maintained. Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org
This commit is contained in:
parent
dd94888938
commit
d3acd81ef9
@ -515,6 +515,7 @@ struct afs_vldb_entry {
|
|||||||
#define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
|
#define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
|
||||||
#define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
|
#define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
|
||||||
#define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
|
#define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
|
||||||
|
u8 vlsf_flags[AFS_NMAXNSERVERS];
|
||||||
short error;
|
short error;
|
||||||
u8 nr_servers; /* Number of server records */
|
u8 nr_servers; /* Number of server records */
|
||||||
u8 name_len;
|
u8 name_len;
|
||||||
@ -601,6 +602,12 @@ struct afs_server {
|
|||||||
spinlock_t probe_lock;
|
spinlock_t probe_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum afs_ro_replicating {
|
||||||
|
AFS_RO_NOT_REPLICATING, /* Not doing replication */
|
||||||
|
AFS_RO_REPLICATING_USE_OLD, /* Replicating; use old version */
|
||||||
|
AFS_RO_REPLICATING_USE_NEW, /* Replicating; switch to new version */
|
||||||
|
} __mode(byte);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replaceable volume server list.
|
* Replaceable volume server list.
|
||||||
*/
|
*/
|
||||||
@ -608,12 +615,15 @@ struct afs_server_entry {
|
|||||||
struct afs_server *server;
|
struct afs_server *server;
|
||||||
struct afs_volume *volume;
|
struct afs_volume *volume;
|
||||||
struct list_head slink; /* Link in server->volumes */
|
struct list_head slink; /* Link in server->volumes */
|
||||||
|
unsigned long flags;
|
||||||
|
#define AFS_SE_EXCLUDED 0 /* Set if server is to be excluded in rotation */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct afs_server_list {
|
struct afs_server_list {
|
||||||
struct rcu_head rcu;
|
struct rcu_head rcu;
|
||||||
refcount_t usage;
|
refcount_t usage;
|
||||||
bool attached; /* T if attached to servers */
|
bool attached; /* T if attached to servers */
|
||||||
|
enum afs_ro_replicating ro_replicating; /* RW->RO update (probably) in progress */
|
||||||
unsigned char nr_servers;
|
unsigned char nr_servers;
|
||||||
unsigned char preferred; /* Preferred server */
|
unsigned char preferred; /* Preferred server */
|
||||||
unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */
|
unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */
|
||||||
|
@ -448,9 +448,11 @@ pick_server:
|
|||||||
op->server_index = -1;
|
op->server_index = -1;
|
||||||
rtt = UINT_MAX;
|
rtt = UINT_MAX;
|
||||||
for (i = 0; i < op->server_list->nr_servers; i++) {
|
for (i = 0; i < op->server_list->nr_servers; i++) {
|
||||||
struct afs_server *s = op->server_list->servers[i].server;
|
struct afs_server_entry *se = &op->server_list->servers[i];
|
||||||
|
struct afs_server *s = se->server;
|
||||||
|
|
||||||
if (!test_bit(i, &op->untried_servers) ||
|
if (!test_bit(i, &op->untried_servers) ||
|
||||||
|
test_bit(AFS_SE_EXCLUDED, &se->flags) ||
|
||||||
!test_bit(AFS_SERVER_FL_RESPONDING, &s->flags))
|
!test_bit(AFS_SERVER_FL_RESPONDING, &s->flags))
|
||||||
continue;
|
continue;
|
||||||
if (s->rtt <= rtt) {
|
if (s->rtt <= rtt) {
|
||||||
|
@ -31,23 +31,53 @@ struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume,
|
|||||||
struct afs_server_list *slist;
|
struct afs_server_list *slist;
|
||||||
struct afs_server *server;
|
struct afs_server *server;
|
||||||
unsigned int type_mask = 1 << volume->type;
|
unsigned int type_mask = 1 << volume->type;
|
||||||
int ret = -ENOMEM, nr_servers = 0, i, j;
|
bool use_newrepsites = false;
|
||||||
|
int ret = -ENOMEM, nr_servers = 0, newrep = 0, i, j, usable = 0;
|
||||||
|
|
||||||
for (i = 0; i < vldb->nr_servers; i++)
|
/* Work out if we're going to restrict to NEWREPSITE-marked servers or
|
||||||
if (vldb->fs_mask[i] & type_mask)
|
* not. If at least one site is marked as NEWREPSITE, then it's likely
|
||||||
|
* that "vos release" is busy updating RO sites. We cut over from one
|
||||||
|
* to the other when >=50% of the sites have been updated. Sites that
|
||||||
|
* are in the process of being updated are marked DONTUSE.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < vldb->nr_servers; i++) {
|
||||||
|
if (!(vldb->fs_mask[i] & type_mask))
|
||||||
|
continue;
|
||||||
nr_servers++;
|
nr_servers++;
|
||||||
|
if (vldb->vlsf_flags[i] & AFS_VLSF_DONTUSE)
|
||||||
|
continue;
|
||||||
|
usable++;
|
||||||
|
if (vldb->vlsf_flags[i] & AFS_VLSF_NEWREPSITE)
|
||||||
|
newrep++;
|
||||||
|
}
|
||||||
|
|
||||||
slist = kzalloc(struct_size(slist, servers, nr_servers), GFP_KERNEL);
|
slist = kzalloc(struct_size(slist, servers, nr_servers), GFP_KERNEL);
|
||||||
if (!slist)
|
if (!slist)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (newrep) {
|
||||||
|
if (newrep < usable / 2) {
|
||||||
|
slist->ro_replicating = AFS_RO_REPLICATING_USE_OLD;
|
||||||
|
} else {
|
||||||
|
slist->ro_replicating = AFS_RO_REPLICATING_USE_NEW;
|
||||||
|
use_newrepsites = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
refcount_set(&slist->usage, 1);
|
refcount_set(&slist->usage, 1);
|
||||||
rwlock_init(&slist->lock);
|
rwlock_init(&slist->lock);
|
||||||
|
|
||||||
/* Make sure a records exists for each server in the list. */
|
/* Make sure a records exists for each server in the list. */
|
||||||
for (i = 0; i < vldb->nr_servers; i++) {
|
for (i = 0; i < vldb->nr_servers; i++) {
|
||||||
|
unsigned long se_flags = 0;
|
||||||
|
bool newrepsite = vldb->vlsf_flags[i] & AFS_VLSF_NEWREPSITE;
|
||||||
|
|
||||||
if (!(vldb->fs_mask[i] & type_mask))
|
if (!(vldb->fs_mask[i] & type_mask))
|
||||||
continue;
|
continue;
|
||||||
|
if (vldb->vlsf_flags[i] & AFS_VLSF_DONTUSE)
|
||||||
|
__set_bit(AFS_SE_EXCLUDED, &se_flags);
|
||||||
|
if (newrep && (newrepsite ^ use_newrepsites))
|
||||||
|
__set_bit(AFS_SE_EXCLUDED, &se_flags);
|
||||||
|
|
||||||
server = afs_lookup_server(volume->cell, key, &vldb->fs_server[i],
|
server = afs_lookup_server(volume->cell, key, &vldb->fs_server[i],
|
||||||
vldb->addr_version[i]);
|
vldb->addr_version[i]);
|
||||||
@ -79,6 +109,7 @@ struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume,
|
|||||||
|
|
||||||
slist->servers[j].server = server;
|
slist->servers[j].server = server;
|
||||||
slist->servers[j].volume = volume;
|
slist->servers[j].volume = volume;
|
||||||
|
slist->servers[j].flags = se_flags;
|
||||||
slist->nr_servers++;
|
slist->nr_servers++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,16 +132,20 @@ error:
|
|||||||
bool afs_annotate_server_list(struct afs_server_list *new,
|
bool afs_annotate_server_list(struct afs_server_list *new,
|
||||||
struct afs_server_list *old)
|
struct afs_server_list *old)
|
||||||
{
|
{
|
||||||
|
unsigned long mask = 1UL << AFS_SE_EXCLUDED;
|
||||||
struct afs_server *cur;
|
struct afs_server *cur;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (old->nr_servers != new->nr_servers)
|
if (old->nr_servers != new->nr_servers ||
|
||||||
|
old->ro_replicating != new->ro_replicating)
|
||||||
goto changed;
|
goto changed;
|
||||||
|
|
||||||
for (i = 0; i < old->nr_servers; i++)
|
for (i = 0; i < old->nr_servers; i++) {
|
||||||
if (old->servers[i].server != new->servers[i].server)
|
if (old->servers[i].server != new->servers[i].server)
|
||||||
goto changed;
|
goto changed;
|
||||||
|
if ((old->servers[i].flags & mask) != (new->servers[i].flags & mask))
|
||||||
|
goto changed;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
changed:
|
changed:
|
||||||
@ -118,6 +153,7 @@ changed:
|
|||||||
cur = old->servers[old->preferred].server;
|
cur = old->servers[old->preferred].server;
|
||||||
for (j = 0; j < new->nr_servers; j++) {
|
for (j = 0; j < new->nr_servers; j++) {
|
||||||
if (new->servers[j].server == cur) {
|
if (new->servers[j].server == cur) {
|
||||||
|
if (!test_bit(AFS_SE_EXCLUDED, &new->servers[j].flags))
|
||||||
new->preferred = j;
|
new->preferred = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
|
|||||||
{
|
{
|
||||||
struct afs_uvldbentry__xdr *uvldb;
|
struct afs_uvldbentry__xdr *uvldb;
|
||||||
struct afs_vldb_entry *entry;
|
struct afs_vldb_entry *entry;
|
||||||
bool new_only = false;
|
u32 nr_servers, vlflags;
|
||||||
u32 tmp, nr_servers, vlflags;
|
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
_enter("");
|
_enter("");
|
||||||
@ -41,27 +40,14 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
|
|||||||
entry->name[i] = 0;
|
entry->name[i] = 0;
|
||||||
entry->name_len = strlen(entry->name);
|
entry->name_len = strlen(entry->name);
|
||||||
|
|
||||||
/* If there is a new replication site that we can use, ignore all the
|
|
||||||
* sites that aren't marked as new.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < nr_servers; i++) {
|
|
||||||
tmp = ntohl(uvldb->serverFlags[i]);
|
|
||||||
if (!(tmp & AFS_VLSF_DONTUSE) &&
|
|
||||||
(tmp & AFS_VLSF_NEWREPSITE))
|
|
||||||
new_only = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
vlflags = ntohl(uvldb->flags);
|
vlflags = ntohl(uvldb->flags);
|
||||||
for (i = 0; i < nr_servers; i++) {
|
for (i = 0; i < nr_servers; i++) {
|
||||||
struct afs_uuid__xdr *xdr;
|
struct afs_uuid__xdr *xdr;
|
||||||
struct afs_uuid *uuid;
|
struct afs_uuid *uuid;
|
||||||
|
u32 tmp = ntohl(uvldb->serverFlags[i]);
|
||||||
int j;
|
int j;
|
||||||
int n = entry->nr_servers;
|
int n = entry->nr_servers;
|
||||||
|
|
||||||
tmp = ntohl(uvldb->serverFlags[i]);
|
|
||||||
if (tmp & AFS_VLSF_DONTUSE ||
|
|
||||||
(new_only && !(tmp & AFS_VLSF_NEWREPSITE)))
|
|
||||||
continue;
|
|
||||||
if (tmp & AFS_VLSF_RWVOL) {
|
if (tmp & AFS_VLSF_RWVOL) {
|
||||||
entry->fs_mask[n] |= AFS_VOL_VTM_RW;
|
entry->fs_mask[n] |= AFS_VOL_VTM_RW;
|
||||||
if (vlflags & AFS_VLF_BACKEXISTS)
|
if (vlflags & AFS_VLF_BACKEXISTS)
|
||||||
@ -82,6 +68,7 @@ static int afs_deliver_vl_get_entry_by_name_u(struct afs_call *call)
|
|||||||
for (j = 0; j < 6; j++)
|
for (j = 0; j < 6; j++)
|
||||||
uuid->node[j] = (u8)ntohl(xdr->node[j]);
|
uuid->node[j] = (u8)ntohl(xdr->node[j]);
|
||||||
|
|
||||||
|
entry->vlsf_flags[n] = tmp;
|
||||||
entry->addr_version[n] = ntohl(uvldb->serverUnique[i]);
|
entry->addr_version[n] = ntohl(uvldb->serverUnique[i]);
|
||||||
entry->nr_servers++;
|
entry->nr_servers++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user