函数源码 |
Source File:lib\raid6\algos.c |
Create Date:2022-07-27 08:07:10 |
首页 | Copyright©Brick |
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | /* Try to pick the best algorithm */ /* This code uses the gfmul table as convenient data set to abuse */ int __init raid6_select_algo( void ) { const int disks = (65536/PAGE_SIZE)+2; const struct raid6_calls *gen_best; const struct raid6_recov_calls *rec_best; char *syndromes; void *dptrs[(65536/PAGE_SIZE)+2]; int i; for (i = 0; i < disks-2; i++) dptrs[i] = (( char *)raid6_gfmul) + PAGE_SIZE*i; /* Normal code - use a 2-page allocation to avoid D$ conflict */ syndromes = ( void *) __get_free_pages(GFP_KERNEL, 1); if (!syndromes) { pr_err( "raid6: Yikes! No memory available.\n" ); return -ENOMEM; } dptrs[disks-2] = syndromes; dptrs[disks-1] = syndromes + PAGE_SIZE; /* select raid gen_syndrome function */ gen_best = raid6_choose_gen(&dptrs, disks); /* select raid recover functions */ rec_best = raid6_choose_recov(); free_pages((unsigned long )syndromes, 1); return gen_best && rec_best ? 0 : -EINVAL; } |