diff options
-rw-r--r-- | fs/nfs/pnfs.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 519ad320f5cd..cd8b5fca33f6 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -768,17 +768,32 @@ pnfs_destroy_all_layouts(struct nfs_client *clp) | |||
768 | pnfs_destroy_layouts_byclid(clp, false); | 768 | pnfs_destroy_layouts_byclid(clp, false); |
769 | } | 769 | } |
770 | 770 | ||
771 | static void | ||
772 | pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo) | ||
773 | { | ||
774 | lo->plh_return_iomode = 0; | ||
775 | lo->plh_return_seq = 0; | ||
776 | clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); | ||
777 | } | ||
778 | |||
771 | /* update lo->plh_stateid with new if is more recent */ | 779 | /* update lo->plh_stateid with new if is more recent */ |
772 | void | 780 | void |
773 | pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | 781 | pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, |
774 | bool update_barrier) | 782 | bool update_barrier) |
775 | { | 783 | { |
776 | u32 oldseq, newseq, new_barrier = 0; | 784 | u32 oldseq, newseq, new_barrier = 0; |
777 | bool invalid = !pnfs_layout_is_valid(lo); | ||
778 | 785 | ||
779 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); | 786 | oldseq = be32_to_cpu(lo->plh_stateid.seqid); |
780 | newseq = be32_to_cpu(new->seqid); | 787 | newseq = be32_to_cpu(new->seqid); |
781 | if (invalid || pnfs_seqid_is_newer(newseq, oldseq)) { | 788 | |
789 | if (!pnfs_layout_is_valid(lo)) { | ||
790 | nfs4_stateid_copy(&lo->plh_stateid, new); | ||
791 | lo->plh_barrier = newseq; | ||
792 | pnfs_clear_layoutreturn_info(lo); | ||
793 | clear_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); | ||
794 | return; | ||
795 | } | ||
796 | if (pnfs_seqid_is_newer(newseq, oldseq)) { | ||
782 | nfs4_stateid_copy(&lo->plh_stateid, new); | 797 | nfs4_stateid_copy(&lo->plh_stateid, new); |
783 | /* | 798 | /* |
784 | * Because of wraparound, we want to keep the barrier | 799 | * Because of wraparound, we want to keep the barrier |
@@ -790,7 +805,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new, | |||
790 | new_barrier = be32_to_cpu(new->seqid); | 805 | new_barrier = be32_to_cpu(new->seqid); |
791 | else if (new_barrier == 0) | 806 | else if (new_barrier == 0) |
792 | return; | 807 | return; |
793 | if (invalid || pnfs_seqid_is_newer(new_barrier, lo->plh_barrier)) | 808 | if (pnfs_seqid_is_newer(new_barrier, lo->plh_barrier)) |
794 | lo->plh_barrier = new_barrier; | 809 | lo->plh_barrier = new_barrier; |
795 | } | 810 | } |
796 | 811 | ||
@@ -886,14 +901,6 @@ void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo) | |||
886 | rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq); | 901 | rpc_wake_up(&NFS_SERVER(lo->plh_inode)->roc_rpcwaitq); |
887 | } | 902 | } |
888 | 903 | ||
889 | static void | ||
890 | pnfs_clear_layoutreturn_info(struct pnfs_layout_hdr *lo) | ||
891 | { | ||
892 | lo->plh_return_iomode = 0; | ||
893 | lo->plh_return_seq = 0; | ||
894 | clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); | ||
895 | } | ||
896 | |||
897 | static bool | 904 | static bool |
898 | pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, | 905 | pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo, |
899 | nfs4_stateid *stateid, | 906 | nfs4_stateid *stateid, |
@@ -1801,16 +1808,11 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) | |||
1801 | */ | 1808 | */ |
1802 | pnfs_mark_layout_stateid_invalid(lo, &free_me); | 1809 | pnfs_mark_layout_stateid_invalid(lo, &free_me); |
1803 | 1810 | ||
1804 | nfs4_stateid_copy(&lo->plh_stateid, &res->stateid); | 1811 | pnfs_set_layout_stateid(lo, &res->stateid, true); |
1805 | lo->plh_barrier = be32_to_cpu(res->stateid.seqid); | ||
1806 | } | 1812 | } |
1807 | 1813 | ||
1808 | pnfs_get_lseg(lseg); | 1814 | pnfs_get_lseg(lseg); |
1809 | pnfs_layout_insert_lseg(lo, lseg, &free_me); | 1815 | pnfs_layout_insert_lseg(lo, lseg, &free_me); |
1810 | if (!pnfs_layout_is_valid(lo)) { | ||
1811 | pnfs_clear_layoutreturn_info(lo); | ||
1812 | clear_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); | ||
1813 | } | ||
1814 | 1816 | ||
1815 | 1817 | ||
1816 | if (res->return_on_close) | 1818 | if (res->return_on_close) |