aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_file.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index dc0e4cb7029b..5fb5a0958a14 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1052,29 +1052,8 @@ xfs_find_get_desired_pgoff(
1052 want = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1; 1052 want = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1;
1053 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index, 1053 nr_pages = pagevec_lookup(&pvec, inode->i_mapping, index,
1054 want); 1054 want);
1055 /* 1055 if (nr_pages == 0)
1056 * No page mapped into given range. If we are searching holes
1057 * and if this is the first time we got into the loop, it means
1058 * that the given offset is landed in a hole, return it.
1059 *
1060 * If we have already stepped through some block buffers to find
1061 * holes but they all contains data. In this case, the last
1062 * offset is already updated and pointed to the end of the last
1063 * mapped page, if it does not reach the endpoint to search,
1064 * that means there should be a hole between them.
1065 */
1066 if (nr_pages == 0) {
1067 /* Data search found nothing */
1068 if (type == DATA_OFF)
1069 break;
1070
1071 ASSERT(type == HOLE_OFF);
1072 if (lastoff == startoff || lastoff < endoff) {
1073 found = true;
1074 *offset = lastoff;
1075 }
1076 break; 1056 break;
1077 }
1078 1057
1079 for (i = 0; i < nr_pages; i++) { 1058 for (i = 0; i < nr_pages; i++) {
1080 struct page *page = pvec.pages[i]; 1059 struct page *page = pvec.pages[i];
@@ -1140,21 +1119,20 @@ xfs_find_get_desired_pgoff(
1140 1119
1141 /* 1120 /*
1142 * The number of returned pages less than our desired, search 1121 * The number of returned pages less than our desired, search
1143 * done. In this case, nothing was found for searching data, 1122 * done.
1144 * but we found a hole behind the last offset.
1145 */ 1123 */
1146 if (nr_pages < want) { 1124 if (nr_pages < want)
1147 if (type == HOLE_OFF) {
1148 *offset = lastoff;
1149 found = true;
1150 }
1151 break; 1125 break;
1152 }
1153 1126
1154 index = pvec.pages[i - 1]->index + 1; 1127 index = pvec.pages[i - 1]->index + 1;
1155 pagevec_release(&pvec); 1128 pagevec_release(&pvec);
1156 } while (index <= end); 1129 } while (index <= end);
1157 1130
1131 /* No page at lastoff and we are not done - we found a hole. */
1132 if (type == HOLE_OFF && lastoff < endoff) {
1133 *offset = lastoff;
1134 found = true;
1135 }
1158out: 1136out:
1159 pagevec_release(&pvec); 1137 pagevec_release(&pvec);
1160 return found; 1138 return found;