| .. | .. |
|---|
| 3 | 3 | * Copyright (c) 2017 Christoph Hellwig. |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | | -#include <linux/cache.h> |
|---|
| 7 | | -#include <linux/kernel.h> |
|---|
| 8 | | -#include <linux/slab.h> |
|---|
| 9 | 6 | #include "xfs.h" |
|---|
| 7 | +#include "xfs_shared.h" |
|---|
| 10 | 8 | #include "xfs_format.h" |
|---|
| 11 | 9 | #include "xfs_bit.h" |
|---|
| 12 | 10 | #include "xfs_log_format.h" |
|---|
| 13 | 11 | #include "xfs_inode.h" |
|---|
| 14 | | -#include "xfs_inode_fork.h" |
|---|
| 15 | 12 | #include "xfs_trans_resv.h" |
|---|
| 16 | 13 | #include "xfs_mount.h" |
|---|
| 17 | | -#include "xfs_bmap.h" |
|---|
| 18 | 14 | #include "xfs_trace.h" |
|---|
| 19 | 15 | |
|---|
| 20 | 16 | /* |
|---|
| .. | .. |
|---|
| 600 | 596 | struct xfs_ifork *ifp, |
|---|
| 601 | 597 | struct xfs_iext_cursor *cur) |
|---|
| 602 | 598 | { |
|---|
| 603 | | - size_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec); |
|---|
| 599 | + int64_t new_size = ifp->if_bytes + sizeof(struct xfs_iext_rec); |
|---|
| 604 | 600 | void *new; |
|---|
| 605 | 601 | |
|---|
| 606 | 602 | /* account for the prev/next pointers */ |
|---|
| 607 | 603 | if (new_size / sizeof(struct xfs_iext_rec) == RECS_PER_LEAF) |
|---|
| 608 | 604 | new_size = NODE_SIZE; |
|---|
| 609 | 605 | |
|---|
| 610 | | - new = kmem_realloc(ifp->if_u1.if_root, new_size, KM_NOFS); |
|---|
| 606 | + new = krealloc(ifp->if_u1.if_root, new_size, GFP_NOFS | __GFP_NOFAIL); |
|---|
| 611 | 607 | memset(new + ifp->if_bytes, 0, new_size - ifp->if_bytes); |
|---|
| 612 | 608 | ifp->if_u1.if_root = new; |
|---|
| 613 | 609 | cur->leaf = new; |
|---|
| 614 | 610 | } |
|---|
| 615 | 611 | |
|---|
| 616 | 612 | /* |
|---|
| 617 | | - * Increment the sequence counter if we are on a COW fork. This allows |
|---|
| 618 | | - * the writeback code to skip looking for a COW extent if the COW fork |
|---|
| 619 | | - * hasn't changed. We use WRITE_ONCE here to ensure the update to the |
|---|
| 620 | | - * sequence counter is seen before the modifications to the extent |
|---|
| 621 | | - * tree itself take effect. |
|---|
| 613 | + * Increment the sequence counter on extent tree changes. If we are on a COW |
|---|
| 614 | + * fork, this allows the writeback code to skip looking for a COW extent if the |
|---|
| 615 | + * COW fork hasn't changed. We use WRITE_ONCE here to ensure the update to the |
|---|
| 616 | + * sequence counter is seen before the modifications to the extent tree itself |
|---|
| 617 | + * take effect. |
|---|
| 622 | 618 | */ |
|---|
| 623 | | -static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp, int state) |
|---|
| 619 | +static inline void xfs_iext_inc_seq(struct xfs_ifork *ifp) |
|---|
| 624 | 620 | { |
|---|
| 625 | | - if (state & BMAP_COWFORK) |
|---|
| 626 | | - WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1); |
|---|
| 621 | + WRITE_ONCE(ifp->if_seq, READ_ONCE(ifp->if_seq) + 1); |
|---|
| 627 | 622 | } |
|---|
| 628 | 623 | |
|---|
| 629 | 624 | void |
|---|
| .. | .. |
|---|
| 638 | 633 | struct xfs_iext_leaf *new = NULL; |
|---|
| 639 | 634 | int nr_entries, i; |
|---|
| 640 | 635 | |
|---|
| 641 | | - xfs_iext_inc_seq(ifp, state); |
|---|
| 636 | + xfs_iext_inc_seq(ifp); |
|---|
| 642 | 637 | |
|---|
| 643 | 638 | if (ifp->if_height == 0) |
|---|
| 644 | 639 | xfs_iext_alloc_root(ifp, cur); |
|---|
| .. | .. |
|---|
| 880 | 875 | ASSERT(ifp->if_u1.if_root != NULL); |
|---|
| 881 | 876 | ASSERT(xfs_iext_valid(ifp, cur)); |
|---|
| 882 | 877 | |
|---|
| 883 | | - xfs_iext_inc_seq(ifp, state); |
|---|
| 878 | + xfs_iext_inc_seq(ifp); |
|---|
| 884 | 879 | |
|---|
| 885 | 880 | nr_entries = xfs_iext_leaf_nr_entries(ifp, leaf, cur->pos) - 1; |
|---|
| 886 | 881 | for (i = cur->pos; i < nr_entries; i++) |
|---|
| .. | .. |
|---|
| 988 | 983 | { |
|---|
| 989 | 984 | struct xfs_ifork *ifp = xfs_iext_state_to_fork(ip, state); |
|---|
| 990 | 985 | |
|---|
| 991 | | - xfs_iext_inc_seq(ifp, state); |
|---|
| 986 | + xfs_iext_inc_seq(ifp); |
|---|
| 992 | 987 | |
|---|
| 993 | 988 | if (cur->pos == 0) { |
|---|
| 994 | 989 | struct xfs_bmbt_irec old; |
|---|