Skip to content

Commit 93aaa83

Browse files
committed
Merge tag 'xfs-pnfs-for-linus-3.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs
Pull xfs pnfs block layout support from Dave Chinner: "This contains the changes to XFS needed to support the PNFS block layout server that you pulled in through Bruce's NFS server tree merge. I originally thought that I'd need to merge changes into the NFS server side, but Bruce had already picked them up and so this is purely changes to the fs/xfs/ codebase. Summary: This update contains the implementation of the PNFS server export methods that enable use of XFS filesystems as a block layout target" * tag 'xfs-pnfs-for-linus-3.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs: xfs: recall pNFS layouts on conflicting access xfs: implement pNFS export operations
2 parents 24a52e4 + 781355c commit 93aaa83

File tree

10 files changed

+393
-8
lines changed

10 files changed

+393
-8
lines changed

fs/xfs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
121121
xfs-$(CONFIG_PROC_FS) += xfs_stats.o
122122
xfs-$(CONFIG_SYSCTL) += xfs_sysctl.o
123123
xfs-$(CONFIG_COMPAT) += xfs_ioctl32.o
124+
xfs-$(CONFIG_NFSD_PNFS) += xfs_pnfs.o

fs/xfs/xfs_export.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "xfs_trace.h"
3131
#include "xfs_icache.h"
3232
#include "xfs_log.h"
33+
#include "xfs_pnfs.h"
3334

3435
/*
3536
* Note that we only accept fileids which are long enough rather than allow
@@ -245,4 +246,9 @@ const struct export_operations xfs_export_operations = {
245246
.fh_to_parent = xfs_fs_fh_to_parent,
246247
.get_parent = xfs_fs_get_parent,
247248
.commit_metadata = xfs_fs_nfs_commit_metadata,
249+
#ifdef CONFIG_NFSD_PNFS
250+
.get_uuid = xfs_fs_get_uuid,
251+
.map_blocks = xfs_fs_map_blocks,
252+
.commit_blocks = xfs_fs_commit_blocks,
253+
#endif
248254
};

fs/xfs/xfs_file.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "xfs_trace.h"
3737
#include "xfs_log.h"
3838
#include "xfs_icache.h"
39+
#include "xfs_pnfs.h"
3940

4041
#include <linux/aio.h>
4142
#include <linux/dcache.h>
@@ -554,6 +555,10 @@ xfs_file_aio_write_checks(
554555
if (error)
555556
return error;
556557

558+
error = xfs_break_layouts(inode, iolock);
559+
if (error)
560+
return error;
561+
557562
/*
558563
* If the offset is beyond the size of the file, we need to zero any
559564
* blocks that fall between the existing EOF and the start of this
@@ -822,6 +827,7 @@ xfs_file_fallocate(
822827
struct xfs_inode *ip = XFS_I(inode);
823828
long error;
824829
enum xfs_prealloc_flags flags = 0;
830+
uint iolock = XFS_IOLOCK_EXCL;
825831
loff_t new_size = 0;
826832

827833
if (!S_ISREG(inode->i_mode))
@@ -830,7 +836,11 @@ xfs_file_fallocate(
830836
FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE))
831837
return -EOPNOTSUPP;
832838

833-
xfs_ilock(ip, XFS_IOLOCK_EXCL);
839+
xfs_ilock(ip, iolock);
840+
error = xfs_break_layouts(inode, &iolock);
841+
if (error)
842+
goto out_unlock;
843+
834844
if (mode & FALLOC_FL_PUNCH_HOLE) {
835845
error = xfs_free_file_space(ip, offset, len);
836846
if (error)
@@ -894,7 +904,7 @@ xfs_file_fallocate(
894904
}
895905

896906
out_unlock:
897-
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
907+
xfs_iunlock(ip, iolock);
898908
return error;
899909
}
900910

fs/xfs/xfs_fsops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ xfs_growfs_data(
602602
if (!mutex_trylock(&mp->m_growlock))
603603
return -EWOULDBLOCK;
604604
error = xfs_growfs_data_private(mp, in);
605+
/*
606+
* Increment the generation unconditionally, the error could be from
607+
* updating the secondary superblocks, in which case the new size
608+
* is live already.
609+
*/
610+
mp->m_generation++;
605611
mutex_unlock(&mp->m_growlock);
606612
return error;
607613
}

fs/xfs/xfs_ioctl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "xfs_icache.h"
4040
#include "xfs_symlink.h"
4141
#include "xfs_trans.h"
42+
#include "xfs_pnfs.h"
4243

4344
#include <linux/capability.h>
4445
#include <linux/dcache.h>
@@ -608,6 +609,7 @@ xfs_ioc_space(
608609
{
609610
struct iattr iattr;
610611
enum xfs_prealloc_flags flags = 0;
612+
uint iolock = XFS_IOLOCK_EXCL;
611613
int error;
612614

613615
/*
@@ -636,7 +638,10 @@ xfs_ioc_space(
636638
if (error)
637639
return error;
638640

639-
xfs_ilock(ip, XFS_IOLOCK_EXCL);
641+
xfs_ilock(ip, iolock);
642+
error = xfs_break_layouts(inode, &iolock);
643+
if (error)
644+
goto out_unlock;
640645

641646
switch (bf->l_whence) {
642647
case 0: /*SEEK_SET*/
@@ -725,7 +730,7 @@ xfs_ioc_space(
725730
error = xfs_update_prealloc_flags(ip, flags);
726731

727732
out_unlock:
728-
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
733+
xfs_iunlock(ip, iolock);
729734
mnt_drop_write_file(filp);
730735
return error;
731736
}

fs/xfs/xfs_iops.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "xfs_da_btree.h"
3838
#include "xfs_dir2.h"
3939
#include "xfs_trans_space.h"
40+
#include "xfs_pnfs.h"
4041

4142
#include <linux/capability.h>
4243
#include <linux/xattr.h>
@@ -505,7 +506,7 @@ xfs_setattr_mode(
505506
inode->i_mode |= mode & ~S_IFMT;
506507
}
507508

508-
static void
509+
void
509510
xfs_setattr_time(
510511
struct xfs_inode *ip,
511512
struct iattr *iattr)
@@ -979,9 +980,13 @@ xfs_vn_setattr(
979980
int error;
980981

981982
if (iattr->ia_valid & ATTR_SIZE) {
982-
xfs_ilock(ip, XFS_IOLOCK_EXCL);
983-
error = xfs_setattr_size(ip, iattr);
984-
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
983+
uint iolock = XFS_IOLOCK_EXCL;
984+
985+
xfs_ilock(ip, iolock);
986+
error = xfs_break_layouts(dentry->d_inode, &iolock);
987+
if (!error)
988+
error = xfs_setattr_size(ip, iattr);
989+
xfs_iunlock(ip, iolock);
985990
} else {
986991
error = xfs_setattr_nonsize(ip, iattr, 0);
987992
}

fs/xfs/xfs_iops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern void xfs_setup_inode(struct xfs_inode *);
3232
*/
3333
#define XFS_ATTR_NOACL 0x01 /* Don't call posix_acl_chmod */
3434

35+
extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr);
3536
extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap,
3637
int flags);
3738
extern int xfs_setattr_size(struct xfs_inode *ip, struct iattr *vap);

fs/xfs/xfs_mount.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ typedef struct xfs_mount {
174174
struct workqueue_struct *m_reclaim_workqueue;
175175
struct workqueue_struct *m_log_workqueue;
176176
struct workqueue_struct *m_eofblocks_workqueue;
177+
178+
/*
179+
* Generation of the filesysyem layout. This is incremented by each
180+
* growfs, and used by the pNFS server to ensure the client updates
181+
* its view of the block device once it gets a layout that might
182+
* reference the newly added blocks. Does not need to be persistent
183+
* as long as we only allow file system size increments, but if we
184+
* ever support shrinks it would have to be persisted in addition
185+
* to various other kinds of pain inflicted on the pNFS server.
186+
*/
187+
__uint32_t m_generation;
177188
} xfs_mount_t;
178189

179190
/*

0 commit comments

Comments
 (0)