Skip to content

Commit a64a325

Browse files
committed
Merge tag 'afs-next-20211102' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull AFS updates from David Howells: - Split the readpage handler for symlinks from the one for files. The symlink readpage isn't given a file pointer, so the handling has to be special-cased. This has been posted as part of a patchset to foliate netfs, afs, etc.[1] but I've moved it to this one as it's not actually doing foliation but is more of a pre-cleanup. - Fix file creation to set the mtime from the client's clock to keep make happy if the server's clock isn't quite in sync.[2] Link: https://lore.kernel.org/r/163005742570.2472992.7800423440314043178.stgit@warthog.procyon.org.uk/ [1] Link: http://lists.infradead.org/pipermail/linux-afs/2021-October/004395.html [2] * tag 'afs-next-20211102' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: afs: Set mtime from the client for yfs create operations afs: Sort out symlink reading
2 parents 78805cb + 52af710 commit a64a325

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

fs/afs/file.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
static int afs_file_mmap(struct file *file, struct vm_area_struct *vma);
2121
static int afs_readpage(struct file *file, struct page *page);
22+
static int afs_symlink_readpage(struct file *file, struct page *page);
2223
static void afs_invalidatepage(struct page *page, unsigned int offset,
2324
unsigned int length);
2425
static int afs_releasepage(struct page *page, gfp_t gfp_flags);
@@ -49,7 +50,7 @@ const struct inode_operations afs_file_inode_operations = {
4950
.permission = afs_permission,
5051
};
5152

52-
const struct address_space_operations afs_fs_aops = {
53+
const struct address_space_operations afs_file_aops = {
5354
.readpage = afs_readpage,
5455
.readahead = afs_readahead,
5556
.set_page_dirty = afs_set_page_dirty,
@@ -62,6 +63,12 @@ const struct address_space_operations afs_fs_aops = {
6263
.writepages = afs_writepages,
6364
};
6465

66+
const struct address_space_operations afs_symlink_aops = {
67+
.readpage = afs_symlink_readpage,
68+
.releasepage = afs_releasepage,
69+
.invalidatepage = afs_invalidatepage,
70+
};
71+
6572
static const struct vm_operations_struct afs_vm_ops = {
6673
.open = afs_vm_open,
6774
.close = afs_vm_close,
@@ -313,7 +320,7 @@ static void afs_req_issue_op(struct netfs_read_subrequest *subreq)
313320
afs_put_read(fsreq);
314321
}
315322

316-
static int afs_symlink_readpage(struct page *page)
323+
static int afs_symlink_readpage(struct file *file, struct page *page)
317324
{
318325
struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
319326
struct afs_read *fsreq;
@@ -378,9 +385,6 @@ const struct netfs_read_request_ops afs_req_ops = {
378385

379386
static int afs_readpage(struct file *file, struct page *page)
380387
{
381-
if (!file)
382-
return afs_symlink_readpage(page);
383-
384388
return netfs_readpage(file, page, &afs_req_ops, NULL);
385389
}
386390

fs/afs/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int afs_inode_init_from_status(struct afs_operation *op,
9595
inode->i_mode = S_IFREG | (status->mode & S_IALLUGO);
9696
inode->i_op = &afs_file_inode_operations;
9797
inode->i_fop = &afs_file_operations;
98-
inode->i_mapping->a_ops = &afs_fs_aops;
98+
inode->i_mapping->a_ops = &afs_file_aops;
9999
break;
100100
case AFS_FTYPE_DIR:
101101
inode->i_mode = S_IFDIR | (status->mode & S_IALLUGO);
@@ -113,11 +113,11 @@ static int afs_inode_init_from_status(struct afs_operation *op,
113113
inode->i_mode = S_IFDIR | 0555;
114114
inode->i_op = &afs_mntpt_inode_operations;
115115
inode->i_fop = &afs_mntpt_file_operations;
116-
inode->i_mapping->a_ops = &afs_fs_aops;
116+
inode->i_mapping->a_ops = &afs_symlink_aops;
117117
} else {
118118
inode->i_mode = S_IFLNK | status->mode;
119119
inode->i_op = &afs_symlink_inode_operations;
120-
inode->i_mapping->a_ops = &afs_fs_aops;
120+
inode->i_mapping->a_ops = &afs_symlink_aops;
121121
}
122122
inode_nohighmem(inode);
123123
break;

fs/afs/internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,8 @@ extern void afs_dynroot_depopulate(struct super_block *);
10551055
/*
10561056
* file.c
10571057
*/
1058-
extern const struct address_space_operations afs_fs_aops;
1058+
extern const struct address_space_operations afs_file_aops;
1059+
extern const struct address_space_operations afs_symlink_aops;
10591060
extern const struct inode_operations afs_file_inode_operations;
10601061
extern const struct file_operations afs_file_operations;
10611062
extern const struct netfs_read_request_ops afs_req_ops;

fs/afs/yfsclient.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,18 @@ static s64 linux_to_yfs_time(const struct timespec64 *t)
8383
return (u64)t->tv_sec * 10000000 + t->tv_nsec/100;
8484
}
8585

86-
static __be32 *xdr_encode_YFSStoreStatus_mode(__be32 *bp, mode_t mode)
87-
{
88-
struct yfs_xdr_YFSStoreStatus *x = (void *)bp;
89-
90-
x->mask = htonl(AFS_SET_MODE);
91-
x->mode = htonl(mode & S_IALLUGO);
92-
x->mtime_client = u64_to_xdr(0);
93-
x->owner = u64_to_xdr(0);
94-
x->group = u64_to_xdr(0);
95-
return bp + xdr_size(x);
96-
}
97-
98-
static __be32 *xdr_encode_YFSStoreStatus_mtime(__be32 *bp, const struct timespec64 *t)
86+
static __be32 *xdr_encode_YFSStoreStatus(__be32 *bp, mode_t *mode,
87+
const struct timespec64 *t)
9988
{
10089
struct yfs_xdr_YFSStoreStatus *x = (void *)bp;
90+
mode_t masked_mode = mode ? *mode & S_IALLUGO : 0;
10191
s64 mtime = linux_to_yfs_time(t);
92+
u32 mask = AFS_SET_MTIME;
10293

103-
x->mask = htonl(AFS_SET_MTIME);
104-
x->mode = htonl(0);
94+
mask |= mode ? AFS_SET_MODE : 0;
95+
96+
x->mask = htonl(mask);
97+
x->mode = htonl(masked_mode);
10598
x->mtime_client = u64_to_xdr(mtime);
10699
x->owner = u64_to_xdr(0);
107100
x->group = u64_to_xdr(0);
@@ -576,7 +569,7 @@ void yfs_fs_create_file(struct afs_operation *op)
576569
bp = xdr_encode_u32(bp, 0); /* RPC flags */
577570
bp = xdr_encode_YFSFid(bp, &dvp->fid);
578571
bp = xdr_encode_name(bp, name);
579-
bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode);
572+
bp = xdr_encode_YFSStoreStatus(bp, &op->create.mode, &op->mtime);
580573
bp = xdr_encode_u32(bp, yfs_LockNone); /* ViceLockType */
581574
yfs_check_req(call, bp);
582575

@@ -625,7 +618,7 @@ void yfs_fs_make_dir(struct afs_operation *op)
625618
bp = xdr_encode_u32(bp, 0); /* RPC flags */
626619
bp = xdr_encode_YFSFid(bp, &dvp->fid);
627620
bp = xdr_encode_name(bp, name);
628-
bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode);
621+
bp = xdr_encode_YFSStoreStatus(bp, &op->create.mode, &op->mtime);
629622
yfs_check_req(call, bp);
630623

631624
trace_afs_make_fs_call1(call, &dvp->fid, name);
@@ -946,6 +939,7 @@ void yfs_fs_symlink(struct afs_operation *op)
946939
struct afs_vnode_param *dvp = &op->file[0];
947940
struct afs_call *call;
948941
size_t contents_sz;
942+
mode_t mode = 0777;
949943
__be32 *bp;
950944

951945
_enter("");
@@ -972,7 +966,7 @@ void yfs_fs_symlink(struct afs_operation *op)
972966
bp = xdr_encode_YFSFid(bp, &dvp->fid);
973967
bp = xdr_encode_name(bp, name);
974968
bp = xdr_encode_string(bp, op->create.symlink, contents_sz);
975-
bp = xdr_encode_YFSStoreStatus_mode(bp, S_IRWXUGO);
969+
bp = xdr_encode_YFSStoreStatus(bp, &mode, &op->mtime);
976970
yfs_check_req(call, bp);
977971

978972
trace_afs_make_fs_call1(call, &dvp->fid, name);
@@ -1103,7 +1097,7 @@ void yfs_fs_store_data(struct afs_operation *op)
11031097
bp = xdr_encode_u32(bp, YFSSTOREDATA64);
11041098
bp = xdr_encode_u32(bp, 0); /* RPC flags */
11051099
bp = xdr_encode_YFSFid(bp, &vp->fid);
1106-
bp = xdr_encode_YFSStoreStatus_mtime(bp, &op->mtime);
1100+
bp = xdr_encode_YFSStoreStatus(bp, NULL, &op->mtime);
11071101
bp = xdr_encode_u64(bp, op->store.pos);
11081102
bp = xdr_encode_u64(bp, op->store.size);
11091103
bp = xdr_encode_u64(bp, op->store.i_size);

0 commit comments

Comments
 (0)