dir.c (0eb43812c0270ee3d005ff32f91f7d0a6c4943af) | dir.c (85aa8ddc3818718208c3cfdfda9c8c908c9dead1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/fs/nfs/dir.c 4 * 5 * Copyright (C) 1992 Rick Sladkey 6 * 7 * nfs directory handling functions 8 * --- 1060 unchanged lines hidden (view full) --- 1069 int res; 1070 1071 do { 1072 res = find_and_lock_cache_page(desc); 1073 } while (res == -EAGAIN); 1074 return res; 1075} 1076 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/fs/nfs/dir.c 4 * 5 * Copyright (C) 1992 Rick Sladkey 6 * 7 * nfs directory handling functions 8 * --- 1060 unchanged lines hidden (view full) --- 1069 int res; 1070 1071 do { 1072 res = find_and_lock_cache_page(desc); 1073 } while (res == -EAGAIN); 1074 return res; 1075} 1076 |
1077#define NFS_READDIR_CACHE_MISS_THRESHOLD (16UL) 1078 |
|
1077/* 1078 * Once we've found the start of the dirent within a page: fill 'er up... 1079 */ 1080static void nfs_do_filldir(struct nfs_readdir_descriptor *desc, 1081 const __be32 *verf) 1082{ 1083 struct file *file = desc->file; 1084 struct nfs_cache_array *array; 1085 unsigned int i; | 1079/* 1080 * Once we've found the start of the dirent within a page: fill 'er up... 1081 */ 1082static void nfs_do_filldir(struct nfs_readdir_descriptor *desc, 1083 const __be32 *verf) 1084{ 1085 struct file *file = desc->file; 1086 struct nfs_cache_array *array; 1087 unsigned int i; |
1088 bool first_emit = !desc->dir_cookie; |
|
1086 1087 array = kmap_local_page(desc->page); 1088 for (i = desc->cache_entry_index; i < array->size; i++) { 1089 struct nfs_cache_array_entry *ent; 1090 1091 ent = &array->array[i]; 1092 if (!dir_emit(desc->ctx, ent->name, ent->name_len, 1093 nfs_compat_user_ino64(ent->ino), ent->d_type)) { --- 7 unchanged lines hidden (view full) --- 1101 } else { 1102 desc->dir_cookie = array->array[i + 1].cookie; 1103 desc->last_cookie = array->array[0].cookie; 1104 } 1105 if (nfs_readdir_use_cookie(file)) 1106 desc->ctx->pos = desc->dir_cookie; 1107 else 1108 desc->ctx->pos++; | 1089 1090 array = kmap_local_page(desc->page); 1091 for (i = desc->cache_entry_index; i < array->size; i++) { 1092 struct nfs_cache_array_entry *ent; 1093 1094 ent = &array->array[i]; 1095 if (!dir_emit(desc->ctx, ent->name, ent->name_len, 1096 nfs_compat_user_ino64(ent->ino), ent->d_type)) { --- 7 unchanged lines hidden (view full) --- 1104 } else { 1105 desc->dir_cookie = array->array[i + 1].cookie; 1106 desc->last_cookie = array->array[0].cookie; 1107 } 1108 if (nfs_readdir_use_cookie(file)) 1109 desc->ctx->pos = desc->dir_cookie; 1110 else 1111 desc->ctx->pos++; |
1112 if (first_emit && i > NFS_READDIR_CACHE_MISS_THRESHOLD + 1) { 1113 desc->eob = true; 1114 break; 1115 } |
|
1109 } 1110 if (array->page_is_eof) 1111 desc->eof = !desc->eob; 1112 1113 kunmap_local(array); 1114 dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %llu\n", 1115 (unsigned long long)desc->dir_cookie); 1116} --- 65 unchanged lines hidden (view full) --- 1182 if (!nfs_readdir_use_cookie(desc->file)) 1183 nfs_readdir_rewind_search(desc); 1184 desc->page_index_max = -1; 1185 kfree(arrays); 1186 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __func__, status); 1187 return status; 1188} 1189 | 1116 } 1117 if (array->page_is_eof) 1118 desc->eof = !desc->eob; 1119 1120 kunmap_local(array); 1121 dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %llu\n", 1122 (unsigned long long)desc->dir_cookie); 1123} --- 65 unchanged lines hidden (view full) --- 1189 if (!nfs_readdir_use_cookie(desc->file)) 1190 nfs_readdir_rewind_search(desc); 1191 desc->page_index_max = -1; 1192 kfree(arrays); 1193 dfprintk(DIRCACHE, "NFS: %s: returns %d\n", __func__, status); 1194 return status; 1195} 1196 |
1190#define NFS_READDIR_CACHE_MISS_THRESHOLD (16UL) 1191 | |
1192static bool nfs_readdir_handle_cache_misses(struct inode *inode, 1193 struct nfs_readdir_descriptor *desc, 1194 unsigned int cache_misses, 1195 bool force_clear) 1196{ 1197 if (desc->ctx->pos == 0 || !desc->plus) 1198 return false; 1199 if (cache_misses <= NFS_READDIR_CACHE_MISS_THRESHOLD && !force_clear) --- 2110 unchanged lines hidden --- | 1197static bool nfs_readdir_handle_cache_misses(struct inode *inode, 1198 struct nfs_readdir_descriptor *desc, 1199 unsigned int cache_misses, 1200 bool force_clear) 1201{ 1202 if (desc->ctx->pos == 0 || !desc->plus) 1203 return false; 1204 if (cache_misses <= NFS_READDIR_CACHE_MISS_THRESHOLD && !force_clear) --- 2110 unchanged lines hidden --- |