Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/swap: fold __swap_info_get() into its sole caller

Fold __swap_info_get() into its sole caller to make code more clear.
Minor readability improvement.

Link: https://lkml.kernel.org/r/20220509131416.17553-4-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: NeilBrown <neilb@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Miaohe Lin and committed by
akpm
afba72b1 6106b93e

+6 -18
+6 -18
mm/swapfile.c
··· 1122 1122 return n_ret; 1123 1123 } 1124 1124 1125 - static struct swap_info_struct *__swap_info_get(swp_entry_t entry) 1125 + static struct swap_info_struct *_swap_info_get(swp_entry_t entry) 1126 1126 { 1127 1127 struct swap_info_struct *p; 1128 1128 unsigned long offset; ··· 1137 1137 offset = swp_offset(entry); 1138 1138 if (offset >= p->max) 1139 1139 goto bad_offset; 1140 + if (data_race(!p->swap_map[swp_offset(entry)])) 1141 + goto bad_free; 1140 1142 return p; 1141 1143 1144 + bad_free: 1145 + pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val); 1146 + goto out; 1142 1147 bad_offset: 1143 1148 pr_err("%s: %s%08lx\n", __func__, Bad_offset, entry.val); 1144 1149 goto out; ··· 1152 1147 goto out; 1153 1148 bad_nofile: 1154 1149 pr_err("%s: %s%08lx\n", __func__, Bad_file, entry.val); 1155 - out: 1156 - return NULL; 1157 - } 1158 - 1159 - static struct swap_info_struct *_swap_info_get(swp_entry_t entry) 1160 - { 1161 - struct swap_info_struct *p; 1162 - 1163 - p = __swap_info_get(entry); 1164 - if (!p) 1165 - goto out; 1166 - if (data_race(!p->swap_map[swp_offset(entry)])) 1167 - goto bad_free; 1168 - return p; 1169 - 1170 - bad_free: 1171 - pr_err("%s: %s%08lx\n", __func__, Unused_offset, entry.val); 1172 1150 out: 1173 1151 return NULL; 1174 1152 }