Skip to content

Commit 19e8a2f

Browse files
committed
Merge branch 'afs-dh' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull AFS updates from Al Viro: "The AFS series posted by dhowells depended upon lookup_one_len() rework; now that prereq is in the mainline, that series had been rebased on top of it and got some exposure and testing..." * 'afs-dh' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: afs: Do better accretion of small writes on newly created content afs: Add stats for data transfer operations afs: Trace protocol errors afs: Locally edit directory data for mkdir/create/unlink/... afs: Adjust the directory XDR structures afs: Split the directory content defs into a header afs: Fix directory handling afs: Split the dynroot stuff out and give it its own ops tables afs: Keep track of invalid-before version for dentry coherency afs: Rearrange status mapping afs: Make it possible to get the data version in readpage afs: Init inode before accessing cache afs: Introduce a statistics proc file afs: Dump bad status record afs: Implement @cell substitution handling afs: Implement @sys substitution handling afs: Prospectively look up extra files when doing a single lookup afs: Don't over-increment the cell usage count when pinning it afs: Fix checker warnings vfs: Remove the const from dir_context::actor
2 parents 5d13659 + 5a81327 commit 19e8a2f

28 files changed

Lines changed: 2703 additions & 593 deletions

‎Documentation/filesystems/afs.txt‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Contents:
1111
- Proc filesystem.
1212
- The cell database.
1313
- Security.
14-
- Examples.
14+
- The @sys substitution.
1515

1616

1717
========
@@ -230,3 +230,29 @@ If a file is opened with a particular key and then the file descriptor is
230230
passed to a process that doesn't have that key (perhaps over an AF_UNIX
231231
socket), then the operations on the file will be made with key that was used to
232232
open the file.
233+
234+
235+
=====================
236+
THE @SYS SUBSTITUTION
237+
=====================
238+
239+
The list of up to 16 @sys substitutions for the current network namespace can
240+
be configured by writing a list to /proc/fs/afs/sysname:
241+
242+
[root@andromeda ~]# echo foo amd64_linux_26 >/proc/fs/afs/sysname
243+
244+
or cleared entirely by writing an empty list:
245+
246+
[root@andromeda ~]# echo >/proc/fs/afs/sysname
247+
248+
The current list for current network namespace can be retrieved by:
249+
250+
[root@andromeda ~]# cat /proc/fs/afs/sysname
251+
foo
252+
amd64_linux_26
253+
254+
When @sys is being substituted for, each element of the list is tried in the
255+
order given.
256+
257+
By default, the list will contain one item that conforms to the pattern
258+
"<arch>_linux_26", amd64 being the name for x86_64.

‎fs/afs/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ kafs-objs := \
1212
cell.o \
1313
cmservice.o \
1414
dir.o \
15+
dir_edit.o \
16+
dynroot.o \
1517
file.o \
1618
flock.o \
1719
fsclient.o \

‎fs/afs/addr_list.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port)
243243
xport == a->sin6_port)
244244
return;
245245
if (xdr == a->sin6_addr.s6_addr32[3] &&
246-
xport < a->sin6_port)
246+
(u16 __force)xport < (u16 __force)a->sin6_port)
247247
break;
248-
if (xdr < a->sin6_addr.s6_addr32[3])
248+
if ((u32 __force)xdr < (u32 __force)a->sin6_addr.s6_addr32[3])
249249
break;
250250
}
251251

@@ -280,7 +280,7 @@ void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port)
280280
xport == a->sin6_port)
281281
return;
282282
if (diff == 0 &&
283-
xport < a->sin6_port)
283+
(u16 __force)xport < (u16 __force)a->sin6_port)
284284
break;
285285
if (diff < 0)
286286
break;

‎fs/afs/afs.h‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ typedef enum {
6767
} afs_callback_type_t;
6868

6969
struct afs_callback {
70-
struct afs_fid fid; /* file identifier */
71-
unsigned version; /* callback version */
72-
unsigned expiry; /* time at which expires */
73-
afs_callback_type_t type; /* type of callback */
70+
unsigned version; /* Callback version */
71+
unsigned expiry; /* Time at which expires */
72+
afs_callback_type_t type; /* Type of callback */
73+
};
74+
75+
struct afs_callback_break {
76+
struct afs_fid fid; /* File identifier */
77+
struct afs_callback cb; /* Callback details */
7478
};
7579

7680
#define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
@@ -123,21 +127,20 @@ typedef u32 afs_access_t;
123127
* AFS file status information
124128
*/
125129
struct afs_file_status {
126-
unsigned if_version; /* interface version */
127-
#define AFS_FSTATUS_VERSION 1
130+
u64 size; /* file size */
131+
afs_dataversion_t data_version; /* current data version */
132+
time_t mtime_client; /* last time client changed data */
133+
time_t mtime_server; /* last time server changed data */
134+
unsigned abort_code; /* Abort if bulk-fetching this failed */
128135

129136
afs_file_type_t type; /* file type */
130137
unsigned nlink; /* link count */
131-
u64 size; /* file size */
132-
afs_dataversion_t data_version; /* current data version */
133138
u32 author; /* author ID */
134-
kuid_t owner; /* owner ID */
135-
kgid_t group; /* group ID */
139+
u32 owner; /* owner ID */
140+
u32 group; /* group ID */
136141
afs_access_t caller_access; /* access rights for authenticated caller */
137142
afs_access_t anon_access; /* access rights for unauthenticated caller */
138143
umode_t mode; /* UNIX mode */
139-
time_t mtime_client; /* last time client changed data */
140-
time_t mtime_server; /* last time server changed data */
141144
s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
142145
};
143146

‎fs/afs/afs_fs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ enum AFS_FS_Operations {
3131
FSGETVOLUMEINFO = 148, /* AFS Get information about a volume */
3232
FSGETVOLUMESTATUS = 149, /* AFS Get volume status information */
3333
FSGETROOTVOLUME = 151, /* AFS Get root volume name */
34+
FSBULKSTATUS = 155, /* AFS Fetch multiple file statuses */
3435
FSSETLOCK = 156, /* AFS Request a file lock */
3536
FSEXTENDLOCK = 157, /* AFS Extend a file lock */
3637
FSRELEASELOCK = 158, /* AFS Release a file lock */
3738
FSLOOKUP = 161, /* AFS lookup file in directory */
39+
FSINLINEBULKSTATUS = 65536, /* AFS Fetch multiple file statuses with inline errors */
3840
FSFETCHDATA64 = 65537, /* AFS Fetch file data */
3941
FSSTOREDATA64 = 65538, /* AFS Store file data */
4042
FSGIVEUPALLCALLBACKS = 65539, /* AFS Give up all outstanding callbacks on a server */

‎fs/afs/callback.c‎

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,6 @@ int afs_register_server_cb_interest(struct afs_vnode *vnode,
9696
return 0;
9797
}
9898

99-
/*
100-
* Set a vnode's interest on a server.
101-
*/
102-
void afs_set_cb_interest(struct afs_vnode *vnode, struct afs_cb_interest *cbi)
103-
{
104-
struct afs_cb_interest *old_cbi = NULL;
105-
106-
if (vnode->cb_interest == cbi)
107-
return;
108-
109-
write_seqlock(&vnode->cb_lock);
110-
if (vnode->cb_interest != cbi) {
111-
afs_get_cb_interest(cbi);
112-
old_cbi = vnode->cb_interest;
113-
vnode->cb_interest = cbi;
114-
}
115-
write_sequnlock(&vnode->cb_lock);
116-
afs_put_cb_interest(afs_v2net(vnode), cbi);
117-
}
118-
11999
/*
120100
* Remove an interest on a server.
121101
*/
@@ -150,6 +130,7 @@ void afs_break_callback(struct afs_vnode *vnode)
150130

151131
write_seqlock(&vnode->cb_lock);
152132

133+
clear_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags);
153134
if (test_and_clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) {
154135
vnode->cb_break++;
155136
afs_clear_permits(vnode);
@@ -207,7 +188,7 @@ static void afs_break_one_callback(struct afs_server *server,
207188
* allow the fileserver to break callback promises
208189
*/
209190
void afs_break_callbacks(struct afs_server *server, size_t count,
210-
struct afs_callback callbacks[])
191+
struct afs_callback_break *callbacks)
211192
{
212193
_enter("%p,%zu,", server, count);
213194

@@ -219,9 +200,9 @@ void afs_break_callbacks(struct afs_server *server, size_t count,
219200
callbacks->fid.vid,
220201
callbacks->fid.vnode,
221202
callbacks->fid.unique,
222-
callbacks->version,
223-
callbacks->expiry,
224-
callbacks->type
203+
callbacks->cb.version,
204+
callbacks->cb.expiry,
205+
callbacks->cb.type
225206
);
226207
afs_break_one_callback(server, &callbacks->fid);
227208
}

‎fs/afs/cell.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <keys/rxrpc-type.h>
1919
#include "internal.h"
2020

21-
unsigned __read_mostly afs_cell_gc_delay = 10;
21+
static unsigned __read_mostly afs_cell_gc_delay = 10;
2222

2323
static void afs_manage_cell(struct work_struct *);
2424

@@ -75,7 +75,7 @@ struct afs_cell *afs_lookup_cell_rcu(struct afs_net *net,
7575
cell = rcu_dereference_raw(net->ws_cell);
7676
if (cell) {
7777
afs_get_cell(cell);
78-
continue;
78+
break;
7979
}
8080
ret = -EDESTADDRREQ;
8181
continue;
@@ -130,6 +130,8 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
130130
_leave(" = -ENAMETOOLONG");
131131
return ERR_PTR(-ENAMETOOLONG);
132132
}
133+
if (namelen == 5 && memcmp(name, "@cell", 5) == 0)
134+
return ERR_PTR(-EINVAL);
133135

134136
_enter("%*.*s,%s", namelen, namelen, name, vllist);
135137

@@ -334,8 +336,8 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)
334336
return PTR_ERR(new_root);
335337
}
336338

337-
set_bit(AFS_CELL_FL_NO_GC, &new_root->flags);
338-
afs_get_cell(new_root);
339+
if (!test_and_set_bit(AFS_CELL_FL_NO_GC, &new_root->flags))
340+
afs_get_cell(new_root);
339341

340342
/* install the new cell */
341343
write_seqlock(&net->cells_lock);
@@ -411,7 +413,7 @@ static void afs_cell_destroy(struct rcu_head *rcu)
411413

412414
ASSERTCMP(atomic_read(&cell->usage), ==, 0);
413415

414-
afs_put_addrlist(cell->vl_addrs);
416+
afs_put_addrlist(rcu_access_pointer(cell->vl_addrs));
415417
key_put(cell->anonymous_key);
416418
kfree(cell);
417419

‎fs/afs/cmservice.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ static void SRXAFSCB_CallBack(struct work_struct *work)
178178
*/
179179
static int afs_deliver_cb_callback(struct afs_call *call)
180180
{
181+
struct afs_callback_break *cb;
181182
struct sockaddr_rxrpc srx;
182-
struct afs_callback *cb;
183183
struct afs_server *server;
184184
__be32 *bp;
185185
int ret, loop;
@@ -201,7 +201,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
201201
call->count = ntohl(call->tmp);
202202
_debug("FID count: %u", call->count);
203203
if (call->count > AFSCBMAX)
204-
return -EBADMSG;
204+
return afs_protocol_error(call, -EBADMSG);
205205

206206
call->buffer = kmalloc(call->count * 3 * 4, GFP_KERNEL);
207207
if (!call->buffer)
@@ -218,7 +218,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
218218

219219
_debug("unmarshall FID array");
220220
call->request = kcalloc(call->count,
221-
sizeof(struct afs_callback),
221+
sizeof(struct afs_callback_break),
222222
GFP_KERNEL);
223223
if (!call->request)
224224
return -ENOMEM;
@@ -229,7 +229,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
229229
cb->fid.vid = ntohl(*bp++);
230230
cb->fid.vnode = ntohl(*bp++);
231231
cb->fid.unique = ntohl(*bp++);
232-
cb->type = AFSCM_CB_UNTYPED;
232+
cb->cb.type = AFSCM_CB_UNTYPED;
233233
}
234234

235235
call->offset = 0;
@@ -245,7 +245,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
245245
call->count2 = ntohl(call->tmp);
246246
_debug("CB count: %u", call->count2);
247247
if (call->count2 != call->count && call->count2 != 0)
248-
return -EBADMSG;
248+
return afs_protocol_error(call, -EBADMSG);
249249
call->offset = 0;
250250
call->unmarshall++;
251251

@@ -260,9 +260,9 @@ static int afs_deliver_cb_callback(struct afs_call *call)
260260
cb = call->request;
261261
bp = call->buffer;
262262
for (loop = call->count2; loop > 0; loop--, cb++) {
263-
cb->version = ntohl(*bp++);
264-
cb->expiry = ntohl(*bp++);
265-
cb->type = ntohl(*bp++);
263+
cb->cb.version = ntohl(*bp++);
264+
cb->cb.expiry = ntohl(*bp++);
265+
cb->cb.type = ntohl(*bp++);
266266
}
267267

268268
call->offset = 0;
@@ -500,9 +500,9 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
500500

501501
b = call->buffer;
502502
r = call->request;
503-
r->time_low = ntohl(b[0]);
504-
r->time_mid = ntohl(b[1]);
505-
r->time_hi_and_version = ntohl(b[2]);
503+
r->time_low = b[0];
504+
r->time_mid = htons(ntohl(b[1]));
505+
r->time_hi_and_version = htons(ntohl(b[2]));
506506
r->clock_seq_hi_and_reserved = ntohl(b[3]);
507507
r->clock_seq_low = ntohl(b[4]);
508508

0 commit comments

Comments
 (0)