aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-11-15 10:54:36 -0500
committerDavid S. Miller <davem@davemloft.net>2016-11-15 10:54:36 -0500
commitbb598c1b8c9bf56981927dcb8c0dc34b8ff95342 (patch)
tree69fe6d3bcdbf0acb76e42b144d8af5a0234ccdcb /fs
parenteb2ca35f1814dad3ca547261eedfbbd0d65a0efc (diff)
parente76d21c40bd6c67fd4e2c1540d77e113df962b4d (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Several cases of bug fixes in 'net' overlapping other changes in 'net-next-. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/aio.c207
-rw-r--r--fs/btrfs/extent-tree.c3
-rw-r--r--fs/btrfs/extent_io.c8
-rw-r--r--fs/btrfs/inode.c13
-rw-r--r--fs/btrfs/ioctl.c5
-rw-r--r--fs/btrfs/relocation.c9
-rw-r--r--fs/ceph/file.c1
-rw-r--r--fs/coredump.c3
-rw-r--r--fs/nfs/client.c3
-rw-r--r--fs/nfs/namespace.c2
-rw-r--r--fs/nfs/nfs4session.c12
-rw-r--r--fs/nfs/pnfs.c2
-rw-r--r--fs/nfsd/netns.h5
-rw-r--r--fs/nfsd/nfs4state.c38
-rw-r--r--fs/ntfs/dir.c2
-rw-r--r--fs/ocfs2/dir.c2
-rw-r--r--fs/orangefs/orangefs-debugfs.c147
-rw-r--r--fs/orangefs/orangefs-mod.c6
-rw-r--r--fs/overlayfs/copy_up.c2
-rw-r--r--fs/overlayfs/inode.c3
-rw-r--r--fs/overlayfs/super.c15
-rw-r--r--fs/splice.c5
-rw-r--r--fs/xfs/libxfs/xfs_defer.c17
23 files changed, 268 insertions, 242 deletions
diff --git a/fs/aio.c b/fs/aio.c
index 1157e13a36d6..428484f2f841 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1078,6 +1078,17 @@ static void aio_complete(struct kiocb *kiocb, long res, long res2)
1078 unsigned tail, pos, head; 1078 unsigned tail, pos, head;
1079 unsigned long flags; 1079 unsigned long flags;
1080 1080
1081 if (kiocb->ki_flags & IOCB_WRITE) {
1082 struct file *file = kiocb->ki_filp;
1083
1084 /*
1085 * Tell lockdep we inherited freeze protection from submission
1086 * thread.
1087 */
1088 __sb_writers_acquired(file_inode(file)->i_sb, SB_FREEZE_WRITE);
1089 file_end_write(file);
1090 }
1091
1081 /* 1092 /*
1082 * Special case handling for sync iocbs: 1093 * Special case handling for sync iocbs:
1083 * - events go directly into the iocb for fast handling 1094 * - events go directly into the iocb for fast handling
@@ -1392,122 +1403,106 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
1392 return -EINVAL; 1403 return -EINVAL;
1393} 1404}
1394 1405
1395typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *); 1406static int aio_setup_rw(int rw, struct iocb *iocb, struct iovec **iovec,
1396 1407 bool vectored, bool compat, struct iov_iter *iter)
1397static int aio_setup_vectored_rw(int rw, char __user *buf, size_t len,
1398 struct iovec **iovec,
1399 bool compat,
1400 struct iov_iter *iter)
1401{ 1408{
1409 void __user *buf = (void __user *)(uintptr_t)iocb->aio_buf;
1410 size_t len = iocb->aio_nbytes;
1411
1412 if (!vectored) {
1413 ssize_t ret = import_single_range(rw, buf, len, *iovec, iter);
1414 *iovec = NULL;
1415 return ret;
1416 }
1402#ifdef CONFIG_COMPAT 1417#ifdef CONFIG_COMPAT
1403 if (compat) 1418 if (compat)
1404 return compat_import_iovec(rw, 1419 return compat_import_iovec(rw, buf, len, UIO_FASTIOV, iovec,
1405 (struct compat_iovec __user *)buf, 1420 iter);
1406 len, UIO_FASTIOV, iovec, iter);
1407#endif 1421#endif
1408 return import_iovec(rw, (struct iovec __user *)buf, 1422 return import_iovec(rw, buf, len, UIO_FASTIOV, iovec, iter);
1409 len, UIO_FASTIOV, iovec, iter);
1410} 1423}
1411 1424
1412/* 1425static inline ssize_t aio_ret(struct kiocb *req, ssize_t ret)
1413 * aio_run_iocb: 1426{
1414 * Performs the initial checks and io submission. 1427 switch (ret) {
1415 */ 1428 case -EIOCBQUEUED:
1416static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, 1429 return ret;
1417 char __user *buf, size_t len, bool compat) 1430 case -ERESTARTSYS:
1431 case -ERESTARTNOINTR:
1432 case -ERESTARTNOHAND:
1433 case -ERESTART_RESTARTBLOCK:
1434 /*
1435 * There's no easy way to restart the syscall since other AIO's
1436 * may be already running. Just fail this IO with EINTR.
1437 */
1438 ret = -EINTR;
1439 /*FALLTHRU*/
1440 default:
1441 aio_complete(req, ret, 0);
1442 return 0;
1443 }
1444}
1445
1446static ssize_t aio_read(struct kiocb *req, struct iocb *iocb, bool vectored,
1447 bool compat)
1418{ 1448{
1419 struct file *file = req->ki_filp; 1449 struct file *file = req->ki_filp;
1420 ssize_t ret;
1421 int rw;
1422 fmode_t mode;
1423 rw_iter_op *iter_op;
1424 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; 1450 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;
1425 struct iov_iter iter; 1451 struct iov_iter iter;
1452 ssize_t ret;
1426 1453
1427 switch (opcode) { 1454 if (unlikely(!(file->f_mode & FMODE_READ)))
1428 case IOCB_CMD_PREAD: 1455 return -EBADF;
1429 case IOCB_CMD_PREADV: 1456 if (unlikely(!file->f_op->read_iter))
1430 mode = FMODE_READ; 1457 return -EINVAL;
1431 rw = READ;
1432 iter_op = file->f_op->read_iter;
1433 goto rw_common;
1434
1435 case IOCB_CMD_PWRITE:
1436 case IOCB_CMD_PWRITEV:
1437 mode = FMODE_WRITE;
1438 rw = WRITE;
1439 iter_op = file->f_op->write_iter;
1440 goto rw_common;
1441rw_common:
1442 if (unlikely(!(file->f_mode & mode)))
1443 return -EBADF;
1444
1445 if (!iter_op)
1446 return -EINVAL;
1447
1448 if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV)
1449 ret = aio_setup_vectored_rw(rw, buf, len,
1450 &iovec, compat, &iter);
1451 else {
1452 ret = import_single_range(rw, buf, len, iovec, &iter);
1453 iovec = NULL;
1454 }
1455 if (!ret)
1456 ret = rw_verify_area(rw, file, &req->ki_pos,
1457 iov_iter_count(&iter));
1458 if (ret < 0) {
1459 kfree(iovec);
1460 return ret;
1461 }
1462
1463 if (rw == WRITE)
1464 file_start_write(file);
1465
1466 ret = iter_op(req, &iter);
1467
1468 if (rw == WRITE)
1469 file_end_write(file);
1470 kfree(iovec);
1471 break;
1472
1473 case IOCB_CMD_FDSYNC:
1474 if (!file->f_op->aio_fsync)
1475 return -EINVAL;
1476
1477 ret = file->f_op->aio_fsync(req, 1);
1478 break;
1479 1458
1480 case IOCB_CMD_FSYNC: 1459 ret = aio_setup_rw(READ, iocb, &iovec, vectored, compat, &iter);
1481 if (!file->f_op->aio_fsync) 1460 if (ret)
1482 return -EINVAL; 1461 return ret;
1462 ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter));
1463 if (!ret)
1464 ret = aio_ret(req, file->f_op->read_iter(req, &iter));
1465 kfree(iovec);
1466 return ret;
1467}
1483 1468
1484 ret = file->f_op->aio_fsync(req, 0); 1469static ssize_t aio_write(struct kiocb *req, struct iocb *iocb, bool vectored,
1485 break; 1470 bool compat)
1471{
1472 struct file *file = req->ki_filp;
1473 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;
1474 struct iov_iter iter;
1475 ssize_t ret;
1486 1476
1487 default: 1477 if (unlikely(!(file->f_mode & FMODE_WRITE)))
1488 pr_debug("EINVAL: no operation provided\n"); 1478 return -EBADF;
1479 if (unlikely(!file->f_op->write_iter))
1489 return -EINVAL; 1480 return -EINVAL;
1490 }
1491 1481
1492 if (ret != -EIOCBQUEUED) { 1482 ret = aio_setup_rw(WRITE, iocb, &iovec, vectored, compat, &iter);
1483 if (ret)
1484 return ret;
1485 ret = rw_verify_area(WRITE, file, &req->ki_pos, iov_iter_count(&iter));
1486 if (!ret) {
1487 req->ki_flags |= IOCB_WRITE;
1488 file_start_write(file);
1489 ret = aio_ret(req, file->f_op->write_iter(req, &iter));
1493 /* 1490 /*
1494 * There's no easy way to restart the syscall since other AIO's 1491 * We release freeze protection in aio_complete(). Fool lockdep
1495 * may be already running. Just fail this IO with EINTR. 1492 * by telling it the lock got released so that it doesn't
1493 * complain about held lock when we return to userspace.
1496 */ 1494 */
1497 if (unlikely(ret == -ERESTARTSYS || ret == -ERESTARTNOINTR || 1495 __sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE);
1498 ret == -ERESTARTNOHAND ||
1499 ret == -ERESTART_RESTARTBLOCK))
1500 ret = -EINTR;
1501 aio_complete(req, ret, 0);
1502 } 1496 }
1503 1497 kfree(iovec);
1504 return 0; 1498 return ret;
1505} 1499}
1506 1500
1507static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, 1501static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1508 struct iocb *iocb, bool compat) 1502 struct iocb *iocb, bool compat)
1509{ 1503{
1510 struct aio_kiocb *req; 1504 struct aio_kiocb *req;
1505 struct file *file;
1511 ssize_t ret; 1506 ssize_t ret;
1512 1507
1513 /* enforce forwards compatibility on users */ 1508 /* enforce forwards compatibility on users */
@@ -1530,7 +1525,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1530 if (unlikely(!req)) 1525 if (unlikely(!req))
1531 return -EAGAIN; 1526 return -EAGAIN;
1532 1527
1533 req->common.ki_filp = fget(iocb->aio_fildes); 1528 req->common.ki_filp = file = fget(iocb->aio_fildes);
1534 if (unlikely(!req->common.ki_filp)) { 1529 if (unlikely(!req->common.ki_filp)) {
1535 ret = -EBADF; 1530 ret = -EBADF;
1536 goto out_put_req; 1531 goto out_put_req;
@@ -1565,13 +1560,29 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1565 req->ki_user_iocb = user_iocb; 1560 req->ki_user_iocb = user_iocb;
1566 req->ki_user_data = iocb->aio_data; 1561 req->ki_user_data = iocb->aio_data;
1567 1562
1568 ret = aio_run_iocb(&req->common, iocb->aio_lio_opcode, 1563 get_file(file);
1569 (char __user *)(unsigned long)iocb->aio_buf, 1564 switch (iocb->aio_lio_opcode) {
1570 iocb->aio_nbytes, 1565 case IOCB_CMD_PREAD:
1571 compat); 1566 ret = aio_read(&req->common, iocb, false, compat);
1572 if (ret) 1567 break;
1573 goto out_put_req; 1568 case IOCB_CMD_PWRITE:
1569 ret = aio_write(&req->common, iocb, false, compat);
1570 break;
1571 case IOCB_CMD_PREADV:
1572 ret = aio_read(&req->common, iocb, true, compat);
1573 break;
1574 case IOCB_CMD_PWRITEV:
1575 ret = aio_write(&req->common, iocb, true, compat);
1576 break;
1577 default:
1578 pr_debug("invalid aio operation %d\n", iocb->aio_lio_opcode);
1579 ret = -EINVAL;
1580 break;
1581 }
1582 fput(file);
1574 1583
1584 if (ret && ret != -EIOCBQUEUED)
1585 goto out_put_req;
1575 return 0; 1586 return 0;
1576out_put_req: 1587out_put_req:
1577 put_reqs_available(ctx, 1); 1588 put_reqs_available(ctx, 1);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 210c94ac8818..4607af38c72e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2647,7 +2647,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2647 2647
2648 btrfs_free_delayed_extent_op(extent_op); 2648 btrfs_free_delayed_extent_op(extent_op);
2649 if (ret) { 2649 if (ret) {
2650 spin_lock(&delayed_refs->lock);
2650 locked_ref->processing = 0; 2651 locked_ref->processing = 0;
2652 delayed_refs->num_heads_ready++;
2653 spin_unlock(&delayed_refs->lock);
2651 btrfs_delayed_ref_unlock(locked_ref); 2654 btrfs_delayed_ref_unlock(locked_ref);
2652 btrfs_put_delayed_ref(ref); 2655 btrfs_put_delayed_ref(ref);
2653 btrfs_debug(fs_info, "run_one_delayed_ref returned %d", 2656 btrfs_debug(fs_info, "run_one_delayed_ref returned %d",
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 66a755150056..8ed05d95584a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5569,7 +5569,7 @@ void le_bitmap_set(u8 *map, unsigned int start, int len)
5569 *p |= mask_to_set; 5569 *p |= mask_to_set;
5570 len -= bits_to_set; 5570 len -= bits_to_set;
5571 bits_to_set = BITS_PER_BYTE; 5571 bits_to_set = BITS_PER_BYTE;
5572 mask_to_set = ~(u8)0; 5572 mask_to_set = ~0;
5573 p++; 5573 p++;
5574 } 5574 }
5575 if (len) { 5575 if (len) {
@@ -5589,7 +5589,7 @@ void le_bitmap_clear(u8 *map, unsigned int start, int len)
5589 *p &= ~mask_to_clear; 5589 *p &= ~mask_to_clear;
5590 len -= bits_to_clear; 5590 len -= bits_to_clear;
5591 bits_to_clear = BITS_PER_BYTE; 5591 bits_to_clear = BITS_PER_BYTE;
5592 mask_to_clear = ~(u8)0; 5592 mask_to_clear = ~0;
5593 p++; 5593 p++;
5594 } 5594 }
5595 if (len) { 5595 if (len) {
@@ -5679,7 +5679,7 @@ void extent_buffer_bitmap_set(struct extent_buffer *eb, unsigned long start,
5679 kaddr[offset] |= mask_to_set; 5679 kaddr[offset] |= mask_to_set;
5680 len -= bits_to_set; 5680 len -= bits_to_set;
5681 bits_to_set = BITS_PER_BYTE; 5681 bits_to_set = BITS_PER_BYTE;
5682 mask_to_set = ~(u8)0; 5682 mask_to_set = ~0;
5683 if (++offset >= PAGE_SIZE && len > 0) { 5683 if (++offset >= PAGE_SIZE && len > 0) {
5684 offset = 0; 5684 offset = 0;
5685 page = eb->pages[++i]; 5685 page = eb->pages[++i];
@@ -5721,7 +5721,7 @@ void extent_buffer_bitmap_clear(struct extent_buffer *eb, unsigned long start,
5721 kaddr[offset] &= ~mask_to_clear; 5721 kaddr[offset] &= ~mask_to_clear;
5722 len -= bits_to_clear; 5722 len -= bits_to_clear;
5723 bits_to_clear = BITS_PER_BYTE; 5723 bits_to_clear = BITS_PER_BYTE;
5724 mask_to_clear = ~(u8)0; 5724 mask_to_clear = ~0;
5725 if (++offset >= PAGE_SIZE && len > 0) { 5725 if (++offset >= PAGE_SIZE && len > 0) {
5726 offset = 0; 5726 offset = 0;
5727 page = eb->pages[++i]; 5727 page = eb->pages[++i];
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2b790bda7998..8e3a5a266917 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4605,8 +4605,8 @@ delete:
4605 BUG_ON(ret); 4605 BUG_ON(ret);
4606 if (btrfs_should_throttle_delayed_refs(trans, root)) 4606 if (btrfs_should_throttle_delayed_refs(trans, root))
4607 btrfs_async_run_delayed_refs(root, 4607 btrfs_async_run_delayed_refs(root,
4608 trans->transid, 4608 trans->delayed_ref_updates * 2,
4609 trans->delayed_ref_updates * 2, 0); 4609 trans->transid, 0);
4610 if (be_nice) { 4610 if (be_nice) {
4611 if (truncate_space_check(trans, root, 4611 if (truncate_space_check(trans, root,
4612 extent_num_bytes)) { 4612 extent_num_bytes)) {
@@ -8931,9 +8931,14 @@ again:
8931 * So even we call qgroup_free_data(), it won't decrease reserved 8931 * So even we call qgroup_free_data(), it won't decrease reserved
8932 * space. 8932 * space.
8933 * 2) Not written to disk 8933 * 2) Not written to disk
8934 * This means the reserved space should be freed here. 8934 * This means the reserved space should be freed here. However,
8935 * if a truncate invalidates the page (by clearing PageDirty)
8936 * and the page is accounted for while allocating extent
8937 * in btrfs_check_data_free_space() we let delayed_ref to
8938 * free the entire extent.
8935 */ 8939 */
8936 btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE); 8940 if (PageDirty(page))
8941 btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE);
8937 if (!inode_evicting) { 8942 if (!inode_evicting) {
8938 clear_extent_bit(tree, page_start, page_end, 8943 clear_extent_bit(tree, page_start, page_end,
8939 EXTENT_LOCKED | EXTENT_DIRTY | 8944 EXTENT_LOCKED | EXTENT_DIRTY |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 18e1aa0f85f5..7acbd2cf6192 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3814,6 +3814,11 @@ process_slot:
3814 } 3814 }
3815 btrfs_release_path(path); 3815 btrfs_release_path(path);
3816 key.offset = next_key_min_offset; 3816 key.offset = next_key_min_offset;
3817
3818 if (fatal_signal_pending(current)) {
3819 ret = -EINTR;
3820 goto out;
3821 }
3817 } 3822 }
3818 ret = 0; 3823 ret = 0;
3819 3824
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 0ec8ffa37ab0..c4af0cdb783d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2728,7 +2728,14 @@ static int do_relocation(struct btrfs_trans_handle *trans,
2728 2728
2729 bytenr = btrfs_node_blockptr(upper->eb, slot); 2729 bytenr = btrfs_node_blockptr(upper->eb, slot);
2730 if (lowest) { 2730 if (lowest) {
2731 BUG_ON(bytenr != node->bytenr); 2731 if (bytenr != node->bytenr) {
2732 btrfs_err(root->fs_info,
2733 "lowest leaf/node mismatch: bytenr %llu node->bytenr %llu slot %d upper %llu",
2734 bytenr, node->bytenr, slot,
2735 upper->eb->start);
2736 err = -EIO;
2737 goto next;
2738 }
2732 } else { 2739 } else {
2733 if (node->eb->start == bytenr) 2740 if (node->eb->start == bytenr)
2734 goto next; 2741 goto next;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 18630e800208..f995e3528a33 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1770,7 +1770,6 @@ const struct file_operations ceph_file_fops = {
1770 .fsync = ceph_fsync, 1770 .fsync = ceph_fsync,
1771 .lock = ceph_lock, 1771 .lock = ceph_lock,
1772 .flock = ceph_flock, 1772 .flock = ceph_flock,
1773 .splice_read = generic_file_splice_read,
1774 .splice_write = iter_file_splice_write, 1773 .splice_write = iter_file_splice_write,
1775 .unlocked_ioctl = ceph_ioctl, 1774 .unlocked_ioctl = ceph_ioctl,
1776 .compat_ioctl = ceph_ioctl, 1775 .compat_ioctl = ceph_ioctl,
diff --git a/fs/coredump.c b/fs/coredump.c
index 281b768000e6..eb9c92c9b20f 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1,6 +1,7 @@
1#include <linux/slab.h> 1#include <linux/slab.h>
2#include <linux/file.h> 2#include <linux/file.h>
3#include <linux/fdtable.h> 3#include <linux/fdtable.h>
4#include <linux/freezer.h>
4#include <linux/mm.h> 5#include <linux/mm.h>
5#include <linux/stat.h> 6#include <linux/stat.h>
6#include <linux/fcntl.h> 7#include <linux/fcntl.h>
@@ -423,7 +424,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
423 if (core_waiters > 0) { 424 if (core_waiters > 0) {
424 struct core_thread *ptr; 425 struct core_thread *ptr;
425 426
427 freezer_do_not_count();
426 wait_for_completion(&core_state->startup); 428 wait_for_completion(&core_state->startup);
429 freezer_count();
427 /* 430 /*
428 * Wait for all the threads to become inactive, so that 431 * Wait for all the threads to become inactive, so that
429 * all the thread context (extended register state, like 432 * all the thread context (extended register state, like
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 7555ba889d1f..ebecfb8fba06 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -314,7 +314,8 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
314 /* Match the full socket address */ 314 /* Match the full socket address */
315 if (!rpc_cmp_addr_port(sap, clap)) 315 if (!rpc_cmp_addr_port(sap, clap))
316 /* Match all xprt_switch full socket addresses */ 316 /* Match all xprt_switch full socket addresses */
317 if (!rpc_clnt_xprt_switch_has_addr(clp->cl_rpcclient, 317 if (IS_ERR(clp->cl_rpcclient) ||
318 !rpc_clnt_xprt_switch_has_addr(clp->cl_rpcclient,
318 sap)) 319 sap))
319 continue; 320 continue;
320 321
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index c8162c660c44..5551e8ef67fd 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -98,7 +98,7 @@ rename_retry:
98 return end; 98 return end;
99 } 99 }
100 namelen = strlen(base); 100 namelen = strlen(base);
101 if (flags & NFS_PATH_CANONICAL) { 101 if (*end == '/') {
102 /* Strip off excess slashes in base string */ 102 /* Strip off excess slashes in base string */
103 while (namelen > 0 && base[namelen - 1] == '/') 103 while (namelen > 0 && base[namelen - 1] == '/')
104 namelen--; 104 namelen--;
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
index b62973045a3e..a61350f75c74 100644
--- a/fs/nfs/nfs4session.c
+++ b/fs/nfs/nfs4session.c
@@ -178,12 +178,14 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
178 __must_hold(&tbl->slot_tbl_lock) 178 __must_hold(&tbl->slot_tbl_lock)
179{ 179{
180 struct nfs4_slot *slot; 180 struct nfs4_slot *slot;
181 int ret;
181 182
182 slot = nfs4_lookup_slot(tbl, slotid); 183 slot = nfs4_lookup_slot(tbl, slotid);
183 if (IS_ERR(slot)) 184 ret = PTR_ERR_OR_ZERO(slot);
184 return PTR_ERR(slot); 185 if (!ret)
185 *seq_nr = slot->seq_nr; 186 *seq_nr = slot->seq_nr;
186 return 0; 187
188 return ret;
187} 189}
188 190
189/* 191/*
@@ -196,7 +198,7 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
196static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl, 198static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl,
197 u32 slotid, u32 seq_nr) 199 u32 slotid, u32 seq_nr)
198{ 200{
199 u32 cur_seq; 201 u32 cur_seq = 0;
200 bool ret = false; 202 bool ret = false;
201 203
202 spin_lock(&tbl->slot_tbl_lock); 204 spin_lock(&tbl->slot_tbl_lock);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 56b2d96f9103..259ef85f435a 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -146,6 +146,8 @@ set_pnfs_layoutdriver(struct nfs_server *server, const struct nfs_fh *mntfh,
146 u32 id; 146 u32 id;
147 int i; 147 int i;
148 148
149 if (fsinfo->nlayouttypes == 0)
150 goto out_no_driver;
149 if (!(server->nfs_client->cl_exchange_flags & 151 if (!(server->nfs_client->cl_exchange_flags &
150 (EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_USE_PNFS_MDS))) { 152 (EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_USE_PNFS_MDS))) {
151 printk(KERN_ERR "NFS: %s: cl_exchange_flags 0x%x\n", 153 printk(KERN_ERR "NFS: %s: cl_exchange_flags 0x%x\n",
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
index b10d557f9c9e..ee36efd5aece 100644
--- a/fs/nfsd/netns.h
+++ b/fs/nfsd/netns.h
@@ -84,6 +84,8 @@ struct nfsd_net {
84 struct list_head client_lru; 84 struct list_head client_lru;
85 struct list_head close_lru; 85 struct list_head close_lru;
86 struct list_head del_recall_lru; 86 struct list_head del_recall_lru;
87
88 /* protected by blocked_locks_lock */
87 struct list_head blocked_locks_lru; 89 struct list_head blocked_locks_lru;
88 90
89 struct delayed_work laundromat_work; 91 struct delayed_work laundromat_work;
@@ -91,6 +93,9 @@ struct nfsd_net {
91 /* client_lock protects the client lru list and session hash table */ 93 /* client_lock protects the client lru list and session hash table */
92 spinlock_t client_lock; 94 spinlock_t client_lock;
93 95
96 /* protects blocked_locks_lru */
97 spinlock_t blocked_locks_lock;
98
94 struct file *rec_file; 99 struct file *rec_file;
95 bool in_grace; 100 bool in_grace;
96 const struct nfsd4_client_tracking_ops *client_tracking_ops; 101 const struct nfsd4_client_tracking_ops *client_tracking_ops;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 9752beb78659..4b4beaaa4eaa 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -217,7 +217,7 @@ find_blocked_lock(struct nfs4_lockowner *lo, struct knfsd_fh *fh,
217{ 217{
218 struct nfsd4_blocked_lock *cur, *found = NULL; 218 struct nfsd4_blocked_lock *cur, *found = NULL;
219 219
220 spin_lock(&nn->client_lock); 220 spin_lock(&nn->blocked_locks_lock);
221 list_for_each_entry(cur, &lo->lo_blocked, nbl_list) { 221 list_for_each_entry(cur, &lo->lo_blocked, nbl_list) {
222 if (fh_match(fh, &cur->nbl_fh)) { 222 if (fh_match(fh, &cur->nbl_fh)) {
223 list_del_init(&cur->nbl_list); 223 list_del_init(&cur->nbl_list);
@@ -226,7 +226,7 @@ find_blocked_lock(struct nfs4_lockowner *lo, struct knfsd_fh *fh,
226 break; 226 break;
227 } 227 }
228 } 228 }
229 spin_unlock(&nn->client_lock); 229 spin_unlock(&nn->blocked_locks_lock);
230 if (found) 230 if (found)
231 posix_unblock_lock(&found->nbl_lock); 231 posix_unblock_lock(&found->nbl_lock);
232 return found; 232 return found;
@@ -1227,9 +1227,7 @@ static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp,
1227 1227
1228static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) 1228static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp)
1229{ 1229{
1230 struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner); 1230 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1231
1232 lockdep_assert_held(&oo->oo_owner.so_client->cl_lock);
1233 1231
1234 list_del_init(&stp->st_locks); 1232 list_del_init(&stp->st_locks);
1235 nfs4_unhash_stid(&stp->st_stid); 1233 nfs4_unhash_stid(&stp->st_stid);
@@ -1238,12 +1236,12 @@ static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp)
1238 1236
1239static void release_lock_stateid(struct nfs4_ol_stateid *stp) 1237static void release_lock_stateid(struct nfs4_ol_stateid *stp)
1240{ 1238{
1241 struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner); 1239 struct nfs4_client *clp = stp->st_stid.sc_client;
1242 bool unhashed; 1240 bool unhashed;
1243 1241
1244 spin_lock(&oo->oo_owner.so_client->cl_lock); 1242 spin_lock(&clp->cl_lock);
1245 unhashed = unhash_lock_stateid(stp); 1243 unhashed = unhash_lock_stateid(stp);
1246 spin_unlock(&oo->oo_owner.so_client->cl_lock); 1244 spin_unlock(&clp->cl_lock);
1247 if (unhashed) 1245 if (unhashed)
1248 nfs4_put_stid(&stp->st_stid); 1246 nfs4_put_stid(&stp->st_stid);
1249} 1247}
@@ -4665,7 +4663,7 @@ nfs4_laundromat(struct nfsd_net *nn)
4665 * indefinitely once the lock does become free. 4663 * indefinitely once the lock does become free.
4666 */ 4664 */
4667 BUG_ON(!list_empty(&reaplist)); 4665 BUG_ON(!list_empty(&reaplist));
4668 spin_lock(&nn->client_lock); 4666 spin_lock(&nn->blocked_locks_lock);
4669 while (!list_empty(&nn->blocked_locks_lru)) { 4667 while (!list_empty(&nn->blocked_locks_lru)) {
4670 nbl = list_first_entry(&nn->blocked_locks_lru, 4668 nbl = list_first_entry(&nn->blocked_locks_lru,
4671 struct nfsd4_blocked_lock, nbl_lru); 4669 struct nfsd4_blocked_lock, nbl_lru);
@@ -4678,7 +4676,7 @@ nfs4_laundromat(struct nfsd_net *nn)
4678 list_move(&nbl->nbl_lru, &reaplist); 4676 list_move(&nbl->nbl_lru, &reaplist);
4679 list_del_init(&nbl->nbl_list); 4677 list_del_init(&nbl->nbl_list);
4680 } 4678 }
4681 spin_unlock(&nn->client_lock); 4679 spin_unlock(&nn->blocked_locks_lock);
4682 4680
4683 while (!list_empty(&reaplist)) { 4681 while (!list_empty(&reaplist)) {
4684 nbl = list_first_entry(&nn->blocked_locks_lru, 4682 nbl = list_first_entry(&nn->blocked_locks_lru,
@@ -5439,13 +5437,13 @@ nfsd4_lm_notify(struct file_lock *fl)
5439 bool queue = false; 5437 bool queue = false;
5440 5438
5441 /* An empty list means that something else is going to be using it */ 5439 /* An empty list means that something else is going to be using it */
5442 spin_lock(&nn->client_lock); 5440 spin_lock(&nn->blocked_locks_lock);
5443 if (!list_empty(&nbl->nbl_list)) { 5441 if (!list_empty(&nbl->nbl_list)) {
5444 list_del_init(&nbl->nbl_list); 5442 list_del_init(&nbl->nbl_list);
5445 list_del_init(&nbl->nbl_lru); 5443 list_del_init(&nbl->nbl_lru);
5446 queue = true; 5444 queue = true;
5447 } 5445 }
5448 spin_unlock(&nn->client_lock); 5446 spin_unlock(&nn->blocked_locks_lock);
5449 5447
5450 if (queue) 5448 if (queue)
5451 nfsd4_run_cb(&nbl->nbl_cb); 5449 nfsd4_run_cb(&nbl->nbl_cb);
@@ -5868,10 +5866,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5868 5866
5869 if (fl_flags & FL_SLEEP) { 5867 if (fl_flags & FL_SLEEP) {
5870 nbl->nbl_time = jiffies; 5868 nbl->nbl_time = jiffies;
5871 spin_lock(&nn->client_lock); 5869 spin_lock(&nn->blocked_locks_lock);
5872 list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked); 5870 list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked);
5873 list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru); 5871 list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru);
5874 spin_unlock(&nn->client_lock); 5872 spin_unlock(&nn->blocked_locks_lock);
5875 } 5873 }
5876 5874
5877 err = vfs_lock_file(filp, F_SETLK, file_lock, conflock); 5875 err = vfs_lock_file(filp, F_SETLK, file_lock, conflock);
@@ -5900,10 +5898,10 @@ out:
5900 if (nbl) { 5898 if (nbl) {
5901 /* dequeue it if we queued it before */ 5899 /* dequeue it if we queued it before */
5902 if (fl_flags & FL_SLEEP) { 5900 if (fl_flags & FL_SLEEP) {
5903 spin_lock(&nn->client_lock); 5901 spin_lock(&nn->blocked_locks_lock);
5904 list_del_init(&nbl->nbl_list); 5902 list_del_init(&nbl->nbl_list);
5905 list_del_init(&nbl->nbl_lru); 5903 list_del_init(&nbl->nbl_lru);
5906 spin_unlock(&nn->client_lock); 5904 spin_unlock(&nn->blocked_locks_lock);
5907 } 5905 }
5908 free_blocked_lock(nbl); 5906 free_blocked_lock(nbl);
5909 } 5907 }
@@ -6943,9 +6941,11 @@ static int nfs4_state_create_net(struct net *net)
6943 INIT_LIST_HEAD(&nn->client_lru); 6941 INIT_LIST_HEAD(&nn->client_lru);
6944 INIT_LIST_HEAD(&nn->close_lru); 6942 INIT_LIST_HEAD(&nn->close_lru);
6945 INIT_LIST_HEAD(&nn->del_recall_lru); 6943 INIT_LIST_HEAD(&nn->del_recall_lru);
6946 INIT_LIST_HEAD(&nn->blocked_locks_lru);
6947 spin_lock_init(&nn->client_lock); 6944 spin_lock_init(&nn->client_lock);
6948 6945
6946 spin_lock_init(&nn->blocked_locks_lock);
6947 INIT_LIST_HEAD(&nn->blocked_locks_lru);
6948
6949 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main); 6949 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main);
6950 get_net(net); 6950 get_net(net);
6951 6951
@@ -7063,14 +7063,14 @@ nfs4_state_shutdown_net(struct net *net)
7063 } 7063 }
7064 7064
7065 BUG_ON(!list_empty(&reaplist)); 7065 BUG_ON(!list_empty(&reaplist));
7066 spin_lock(&nn->client_lock); 7066 spin_lock(&nn->blocked_locks_lock);
7067 while (!list_empty(&nn->blocked_locks_lru)) { 7067 while (!list_empty(&nn->blocked_locks_lru)) {
7068 nbl = list_first_entry(&nn->blocked_locks_lru, 7068 nbl = list_first_entry(&nn->blocked_locks_lru,
7069 struct nfsd4_blocked_lock, nbl_lru); 7069 struct nfsd4_blocked_lock, nbl_lru);
7070 list_move(&nbl->nbl_lru, &reaplist); 7070 list_move(&nbl->nbl_lru, &reaplist);
7071 list_del_init(&nbl->nbl_list); 7071 list_del_init(&nbl->nbl_list);
7072 } 7072 }
7073 spin_unlock(&nn->client_lock); 7073 spin_unlock(&nn->blocked_locks_lock);
7074 7074
7075 while (!list_empty(&reaplist)) { 7075 while (!list_empty(&reaplist)) {
7076 nbl = list_first_entry(&nn->blocked_locks_lru, 7076 nbl = list_first_entry(&nn->blocked_locks_lru,
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index a18613579001..0ee19ecc982d 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1544,8 +1544,6 @@ const struct file_operations ntfs_dir_ops = {
1544 .iterate = ntfs_readdir, /* Read directory contents. */ 1544 .iterate = ntfs_readdir, /* Read directory contents. */
1545#ifdef NTFS_RW 1545#ifdef NTFS_RW
1546 .fsync = ntfs_dir_fsync, /* Sync a directory to disk. */ 1546 .fsync = ntfs_dir_fsync, /* Sync a directory to disk. */
1547 /*.aio_fsync = ,*/ /* Sync all outstanding async
1548 i/o operations on a kiocb. */
1549#endif /* NTFS_RW */ 1547#endif /* NTFS_RW */
1550 /*.ioctl = ,*/ /* Perform function on the 1548 /*.ioctl = ,*/ /* Perform function on the
1551 mounted filesystem. */ 1549 mounted filesystem. */
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index e7054e2ac922..3ecb9f337b7d 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -3699,7 +3699,7 @@ static void ocfs2_dx_dir_transfer_leaf(struct inode *dir, u32 split_hash,
3699static int ocfs2_dx_dir_rebalance_credits(struct ocfs2_super *osb, 3699static int ocfs2_dx_dir_rebalance_credits(struct ocfs2_super *osb,
3700 struct ocfs2_dx_root_block *dx_root) 3700 struct ocfs2_dx_root_block *dx_root)
3701{ 3701{
3702 int credits = ocfs2_clusters_to_blocks(osb->sb, 2); 3702 int credits = ocfs2_clusters_to_blocks(osb->sb, 3);
3703 3703
3704 credits += ocfs2_calc_extend_credits(osb->sb, &dx_root->dr_list); 3704 credits += ocfs2_calc_extend_credits(osb->sb, &dx_root->dr_list);
3705 credits += ocfs2_quota_trans_credits(osb->sb); 3705 credits += ocfs2_quota_trans_credits(osb->sb);
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index eb09aa026723..d484068ca716 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -141,6 +141,9 @@ static struct client_debug_mask client_debug_mask;
141 */ 141 */
142static DEFINE_MUTEX(orangefs_debug_lock); 142static DEFINE_MUTEX(orangefs_debug_lock);
143 143
144/* Used to protect data in ORANGEFS_KMOD_DEBUG_HELP_FILE */
145static DEFINE_MUTEX(orangefs_help_file_lock);
146
144/* 147/*
145 * initialize kmod debug operations, create orangefs debugfs dir and 148 * initialize kmod debug operations, create orangefs debugfs dir and
146 * ORANGEFS_KMOD_DEBUG_HELP_FILE. 149 * ORANGEFS_KMOD_DEBUG_HELP_FILE.
@@ -289,6 +292,8 @@ static void *help_start(struct seq_file *m, loff_t *pos)
289 292
290 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "help_start: start\n"); 293 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "help_start: start\n");
291 294
295 mutex_lock(&orangefs_help_file_lock);
296
292 if (*pos == 0) 297 if (*pos == 0)
293 payload = m->private; 298 payload = m->private;
294 299
@@ -305,6 +310,7 @@ static void *help_next(struct seq_file *m, void *v, loff_t *pos)
305static void help_stop(struct seq_file *m, void *p) 310static void help_stop(struct seq_file *m, void *p)
306{ 311{
307 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "help_stop: start\n"); 312 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "help_stop: start\n");
313 mutex_unlock(&orangefs_help_file_lock);
308} 314}
309 315
310static int help_show(struct seq_file *m, void *v) 316static int help_show(struct seq_file *m, void *v)
@@ -610,32 +616,54 @@ out:
610 * /sys/kernel/debug/orangefs/debug-help can be catted to 616 * /sys/kernel/debug/orangefs/debug-help can be catted to
611 * see all the available kernel and client debug keywords. 617 * see all the available kernel and client debug keywords.
612 * 618 *
613 * When the kernel boots, we have no idea what keywords the 619 * When orangefs.ko initializes, we have no idea what keywords the
614 * client supports, nor their associated masks. 620 * client supports, nor their associated masks.
615 * 621 *
616 * We pass through this function once at boot and stamp a 622 * We pass through this function once at module-load and stamp a
617 * boilerplate "we don't know" message for the client in the 623 * boilerplate "we don't know" message for the client in the
618 * debug-help file. We pass through here again when the client 624 * debug-help file. We pass through here again when the client
619 * starts and then we can fill out the debug-help file fully. 625 * starts and then we can fill out the debug-help file fully.
620 * 626 *
621 * The client might be restarted any number of times between 627 * The client might be restarted any number of times between
622 * reboots, we only build the debug-help file the first time. 628 * module reloads, we only build the debug-help file the first time.
623 */ 629 */
624int orangefs_prepare_debugfs_help_string(int at_boot) 630int orangefs_prepare_debugfs_help_string(int at_boot)
625{ 631{
626 int rc = -EINVAL;
627 int i;
628 int byte_count = 0;
629 char *client_title = "Client Debug Keywords:\n"; 632 char *client_title = "Client Debug Keywords:\n";
630 char *kernel_title = "Kernel Debug Keywords:\n"; 633 char *kernel_title = "Kernel Debug Keywords:\n";
634 size_t string_size = DEBUG_HELP_STRING_SIZE;
635 size_t result_size;
636 size_t i;
637 char *new;
638 int rc = -EINVAL;
631 639
632 gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__); 640 gossip_debug(GOSSIP_UTILS_DEBUG, "%s: start\n", __func__);
633 641
634 if (at_boot) { 642 if (at_boot)
635 byte_count += strlen(HELP_STRING_UNINITIALIZED);
636 client_title = HELP_STRING_UNINITIALIZED; 643 client_title = HELP_STRING_UNINITIALIZED;
637 } else { 644
638 /* 645 /* build a new debug_help_string. */
646 new = kzalloc(DEBUG_HELP_STRING_SIZE, GFP_KERNEL);
647 if (!new) {
648 rc = -ENOMEM;
649 goto out;
650 }
651
652 /*
653 * strlcat(dst, src, size) will append at most
654 * "size - strlen(dst) - 1" bytes of src onto dst,
655 * null terminating the result, and return the total
656 * length of the string it tried to create.
657 *
658 * We'll just plow through here building our new debug
659 * help string and let strlcat take care of assuring that
660 * dst doesn't overflow.
661 */
662 strlcat(new, client_title, string_size);
663
664 if (!at_boot) {
665
666 /*
639 * fill the client keyword/mask array and remember 667 * fill the client keyword/mask array and remember
640 * how many elements there were. 668 * how many elements there were.
641 */ 669 */
@@ -644,64 +672,40 @@ int orangefs_prepare_debugfs_help_string(int at_boot)
644 if (cdm_element_count <= 0) 672 if (cdm_element_count <= 0)
645 goto out; 673 goto out;
646 674
647 /* Count the bytes destined for debug_help_string. */
648 byte_count += strlen(client_title);
649
650 for (i = 0; i < cdm_element_count; i++) { 675 for (i = 0; i < cdm_element_count; i++) {
651 byte_count += strlen(cdm_array[i].keyword + 2); 676 strlcat(new, "\t", string_size);
652 if (byte_count >= DEBUG_HELP_STRING_SIZE) { 677 strlcat(new, cdm_array[i].keyword, string_size);
653 pr_info("%s: overflow 1!\n", __func__); 678 strlcat(new, "\n", string_size);
654 goto out;
655 }
656 } 679 }
657
658 gossip_debug(GOSSIP_UTILS_DEBUG,
659 "%s: cdm_element_count:%d:\n",
660 __func__,
661 cdm_element_count);
662 } 680 }
663 681
664 byte_count += strlen(kernel_title); 682 strlcat(new, "\n", string_size);
683 strlcat(new, kernel_title, string_size);
684
665 for (i = 0; i < num_kmod_keyword_mask_map; i++) { 685 for (i = 0; i < num_kmod_keyword_mask_map; i++) {
666 byte_count += 686 strlcat(new, "\t", string_size);
667 strlen(s_kmod_keyword_mask_map[i].keyword + 2); 687 strlcat(new, s_kmod_keyword_mask_map[i].keyword, string_size);
668 if (byte_count >= DEBUG_HELP_STRING_SIZE) { 688 result_size = strlcat(new, "\n", string_size);
669 pr_info("%s: overflow 2!\n", __func__);
670 goto out;
671 }
672 } 689 }
673 690
674 /* build debug_help_string. */ 691 /* See if we tried to put too many bytes into "new"... */
675 debug_help_string = kzalloc(DEBUG_HELP_STRING_SIZE, GFP_KERNEL); 692 if (result_size >= string_size) {
676 if (!debug_help_string) { 693 kfree(new);
677 rc = -ENOMEM;
678 goto out; 694 goto out;
679 } 695 }
680 696
681 strcat(debug_help_string, client_title); 697 if (at_boot) {
682 698 debug_help_string = new;
683 if (!at_boot) { 699 } else {
684 for (i = 0; i < cdm_element_count; i++) { 700 mutex_lock(&orangefs_help_file_lock);
685 strcat(debug_help_string, "\t"); 701 memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE);
686 strcat(debug_help_string, cdm_array[i].keyword); 702 strlcat(debug_help_string, new, string_size);
687 strcat(debug_help_string, "\n"); 703 mutex_unlock(&orangefs_help_file_lock);
688 }
689 }
690
691 strcat(debug_help_string, "\n");
692 strcat(debug_help_string, kernel_title);
693
694 for (i = 0; i < num_kmod_keyword_mask_map; i++) {
695 strcat(debug_help_string, "\t");
696 strcat(debug_help_string, s_kmod_keyword_mask_map[i].keyword);
697 strcat(debug_help_string, "\n");
698 } 704 }
699 705
700 rc = 0; 706 rc = 0;
701 707
702out: 708out: return rc;
703
704 return rc;
705 709
706} 710}
707 711
@@ -959,8 +963,12 @@ int orangefs_debugfs_new_client_string(void __user *arg)
959 ret = copy_from_user(&client_debug_array_string, 963 ret = copy_from_user(&client_debug_array_string,
960 (void __user *)arg, 964 (void __user *)arg,
961 ORANGEFS_MAX_DEBUG_STRING_LEN); 965 ORANGEFS_MAX_DEBUG_STRING_LEN);
962 if (ret != 0) 966
967 if (ret != 0) {
968 pr_info("%s: CLIENT_STRING: copy_from_user failed\n",
969 __func__);
963 return -EIO; 970 return -EIO;
971 }
964 972
965 /* 973 /*
966 * The real client-core makes an effort to ensure 974 * The real client-core makes an effort to ensure
@@ -975,45 +983,18 @@ int orangefs_debugfs_new_client_string(void __user *arg)
975 client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] = 983 client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN - 1] =
976 '\0'; 984 '\0';
977 985
978 if (ret != 0) {
979 pr_info("%s: CLIENT_STRING: copy_from_user failed\n",
980 __func__);
981 return -EIO;
982 }
983
984 pr_info("%s: client debug array string has been received.\n", 986 pr_info("%s: client debug array string has been received.\n",
985 __func__); 987 __func__);
986 988
987 if (!help_string_initialized) { 989 if (!help_string_initialized) {
988 990
989 /* Free the "we don't know yet" default string... */ 991 /* Build a proper debug help string. */
990 kfree(debug_help_string);
991
992 /* build a proper debug help string */
993 if (orangefs_prepare_debugfs_help_string(0)) { 992 if (orangefs_prepare_debugfs_help_string(0)) {
994 gossip_err("%s: no debug help string \n", 993 gossip_err("%s: no debug help string \n",
995 __func__); 994 __func__);
996 return -EIO; 995 return -EIO;
997 } 996 }
998 997
999 /* Replace the boilerplate boot-time debug-help file. */
1000 debugfs_remove(help_file_dentry);
1001
1002 help_file_dentry =
1003 debugfs_create_file(
1004 ORANGEFS_KMOD_DEBUG_HELP_FILE,
1005 0444,
1006 debug_dir,
1007 debug_help_string,
1008 &debug_help_fops);
1009
1010 if (!help_file_dentry) {
1011 gossip_err("%s: debugfs_create_file failed for"
1012 " :%s:!\n",
1013 __func__,
1014 ORANGEFS_KMOD_DEBUG_HELP_FILE);
1015 return -EIO;
1016 }
1017 } 998 }
1018 999
1019 debug_mask_to_string(&client_debug_mask, 1); 1000 debug_mask_to_string(&client_debug_mask, 1);
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 2e5b03065f34..4113eb0495bf 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -124,7 +124,7 @@ static int __init orangefs_init(void)
124 * unknown at boot time. 124 * unknown at boot time.
125 * 125 *
126 * orangefs_prepare_debugfs_help_string will be used again 126 * orangefs_prepare_debugfs_help_string will be used again
127 * later to rebuild the debug-help file after the client starts 127 * later to rebuild the debug-help-string after the client starts
128 * and passes along the needed info. The argument signifies 128 * and passes along the needed info. The argument signifies
129 * which time orangefs_prepare_debugfs_help_string is being 129 * which time orangefs_prepare_debugfs_help_string is being
130 * called. 130 * called.
@@ -152,7 +152,9 @@ static int __init orangefs_init(void)
152 152
153 ret = register_filesystem(&orangefs_fs_type); 153 ret = register_filesystem(&orangefs_fs_type);
154 if (ret == 0) { 154 if (ret == 0) {
155 pr_info("orangefs: module version %s loaded\n", ORANGEFS_VERSION); 155 pr_info("%s: module version %s loaded\n",
156 __func__,
157 ORANGEFS_VERSION);
156 ret = 0; 158 ret = 0;
157 goto out; 159 goto out;
158 } 160 }
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index aeb60f791418..36795eed40b0 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -178,6 +178,8 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len)
178 len -= bytes; 178 len -= bytes;
179 } 179 }
180 180
181 if (!error)
182 error = vfs_fsync(new_file, 0);
181 fput(new_file); 183 fput(new_file);
182out_fput: 184out_fput:
183 fput(old_file); 185 fput(old_file);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index c58f01babf30..7fb53d055537 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -270,9 +270,6 @@ struct posix_acl *ovl_get_acl(struct inode *inode, int type)
270 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode)) 270 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
271 return NULL; 271 return NULL;
272 272
273 if (!realinode->i_op->get_acl)
274 return NULL;
275
276 old_cred = ovl_override_creds(inode->i_sb); 273 old_cred = ovl_override_creds(inode->i_sb);
277 acl = get_acl(realinode, type); 274 acl = get_acl(realinode, type);
278 revert_creds(old_cred); 275 revert_creds(old_cred);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index bcf3965be819..edd46a0e951d 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1037,6 +1037,21 @@ ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
1037 1037
1038 posix_acl_release(acl); 1038 posix_acl_release(acl);
1039 1039
1040 /*
1041 * Check if sgid bit needs to be cleared (actual setacl operation will
1042 * be done with mounter's capabilities and so that won't do it for us).
1043 */
1044 if (unlikely(inode->i_mode & S_ISGID) &&
1045 handler->flags == ACL_TYPE_ACCESS &&
1046 !in_group_p(inode->i_gid) &&
1047 !capable_wrt_inode_uidgid(inode, CAP_FSETID)) {
1048 struct iattr iattr = { .ia_valid = ATTR_KILL_SGID };
1049
1050 err = ovl_setattr(dentry, &iattr);
1051 if (err)
1052 return err;
1053 }
1054
1040 err = ovl_xattr_set(dentry, handler->name, value, size, flags); 1055 err = ovl_xattr_set(dentry, handler->name, value, size, flags);
1041 if (!err) 1056 if (!err)
1042 ovl_copyattr(ovl_inode_real(inode, NULL), inode); 1057 ovl_copyattr(ovl_inode_real(inode, NULL), inode);
diff --git a/fs/splice.c b/fs/splice.c
index 153d4f3bd441..dcaf185a5731 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -299,13 +299,8 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
299{ 299{
300 struct iov_iter to; 300 struct iov_iter to;
301 struct kiocb kiocb; 301 struct kiocb kiocb;
302 loff_t isize;
303 int idx, ret; 302 int idx, ret;
304 303
305 isize = i_size_read(in->f_mapping->host);
306 if (unlikely(*ppos >= isize))
307 return 0;
308
309 iov_iter_pipe(&to, ITER_PIPE | READ, pipe, len); 304 iov_iter_pipe(&to, ITER_PIPE | READ, pipe, len);
310 idx = to.idx; 305 idx = to.idx;
311 init_sync_kiocb(&kiocb, in); 306 init_sync_kiocb(&kiocb, in);
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 613c5cf19436..5c2929f94bd3 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -199,9 +199,9 @@ xfs_defer_intake_work(
199 struct xfs_defer_pending *dfp; 199 struct xfs_defer_pending *dfp;
200 200
201 list_for_each_entry(dfp, &dop->dop_intake, dfp_list) { 201 list_for_each_entry(dfp, &dop->dop_intake, dfp_list) {
202 trace_xfs_defer_intake_work(tp->t_mountp, dfp);
203 dfp->dfp_intent = dfp->dfp_type->create_intent(tp, 202 dfp->dfp_intent = dfp->dfp_type->create_intent(tp,
204 dfp->dfp_count); 203 dfp->dfp_count);
204 trace_xfs_defer_intake_work(tp->t_mountp, dfp);
205 list_sort(tp->t_mountp, &dfp->dfp_work, 205 list_sort(tp->t_mountp, &dfp->dfp_work,
206 dfp->dfp_type->diff_items); 206 dfp->dfp_type->diff_items);
207 list_for_each(li, &dfp->dfp_work) 207 list_for_each(li, &dfp->dfp_work)
@@ -221,21 +221,14 @@ xfs_defer_trans_abort(
221 struct xfs_defer_pending *dfp; 221 struct xfs_defer_pending *dfp;
222 222
223 trace_xfs_defer_trans_abort(tp->t_mountp, dop); 223 trace_xfs_defer_trans_abort(tp->t_mountp, dop);
224 /*
225 * If the transaction was committed, drop the intent reference
226 * since we're bailing out of here. The other reference is
227 * dropped when the intent hits the AIL. If the transaction
228 * was not committed, the intent is freed by the intent item
229 * unlock handler on abort.
230 */
231 if (!dop->dop_committed)
232 return;
233 224
234 /* Abort intent items. */ 225 /* Abort intent items that don't have a done item. */
235 list_for_each_entry(dfp, &dop->dop_pending, dfp_list) { 226 list_for_each_entry(dfp, &dop->dop_pending, dfp_list) {
236 trace_xfs_defer_pending_abort(tp->t_mountp, dfp); 227 trace_xfs_defer_pending_abort(tp->t_mountp, dfp);
237 if (!dfp->dfp_done) 228 if (dfp->dfp_intent && !dfp->dfp_done) {
238 dfp->dfp_type->abort_intent(dfp->dfp_intent); 229 dfp->dfp_type->abort_intent(dfp->dfp_intent);
230 dfp->dfp_intent = NULL;
231 }
239 } 232 }
240 233
241 /* Shut down FS. */ 234 /* Shut down FS. */