xfs_itable.c (6e57c542cb7e0e580eb53ae76a77875c7d92b4b1) | xfs_itable.c (febe3cbe38b0bc0a925906dc90e8d59048851f87) |
---|---|
1/* 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 3 * All Rights Reserved. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * --- 222 unchanged lines hidden (view full) --- 231 232 /* Get the record, should always work */ 233 error = xfs_inobt_get_rec(cur, irec, &stat); 234 if (error) 235 return error; 236 XFS_WANT_CORRUPTED_RETURN(stat == 1); 237 238 /* Check if the record contains the inode in request */ | 1/* 2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 3 * All Rights Reserved. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * --- 222 unchanged lines hidden (view full) --- 231 232 /* Get the record, should always work */ 233 error = xfs_inobt_get_rec(cur, irec, &stat); 234 if (error) 235 return error; 236 XFS_WANT_CORRUPTED_RETURN(stat == 1); 237 238 /* Check if the record contains the inode in request */ |
239 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) 240 return -EINVAL; | 239 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) { 240 *icount = 0; 241 return 0; 242 } |
241 242 idx = agino - irec->ir_startino + 1; 243 if (idx < XFS_INODES_PER_CHUNK && 244 (xfs_inobt_maskn(idx, XFS_INODES_PER_CHUNK - idx) & ~irec->ir_free)) { 245 int i; 246 247 /* We got a right chunk with some left inodes allocated at it. 248 * Grab the chunk record. Mark all the uninteresting inodes --- 98 unchanged lines hidden (view full) --- 347 xfs_agi_t *agi; /* agi header data */ 348 xfs_agino_t agino; /* inode # in allocation group */ 349 xfs_agnumber_t agno; /* allocation group number */ 350 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ 351 size_t irbsize; /* size of irec buffer in bytes */ 352 xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ 353 xfs_ino_t lastino; /* last inode number returned */ 354 int nirbuf; /* size of irbuf */ | 243 244 idx = agino - irec->ir_startino + 1; 245 if (idx < XFS_INODES_PER_CHUNK && 246 (xfs_inobt_maskn(idx, XFS_INODES_PER_CHUNK - idx) & ~irec->ir_free)) { 247 int i; 248 249 /* We got a right chunk with some left inodes allocated at it. 250 * Grab the chunk record. Mark all the uninteresting inodes --- 98 unchanged lines hidden (view full) --- 349 xfs_agi_t *agi; /* agi header data */ 350 xfs_agino_t agino; /* inode # in allocation group */ 351 xfs_agnumber_t agno; /* allocation group number */ 352 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ 353 size_t irbsize; /* size of irec buffer in bytes */ 354 xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ 355 xfs_ino_t lastino; /* last inode number returned */ 356 int nirbuf; /* size of irbuf */ |
355 int rval; /* return value error code */ | |
356 int ubcount; /* size of user's buffer */ 357 struct xfs_bulkstat_agichunk ac; 358 int error = 0; 359 360 /* 361 * Get the last inode value, see if there's nothing to do. 362 */ 363 lastino = *lastinop; --- 19 unchanged lines hidden (view full) --- 383 return -ENOMEM; 384 385 nirbuf = irbsize / sizeof(*irbuf); 386 387 /* 388 * Loop over the allocation groups, starting from the last 389 * inode returned; 0 means start of the allocation group. 390 */ | 357 int ubcount; /* size of user's buffer */ 358 struct xfs_bulkstat_agichunk ac; 359 int error = 0; 360 361 /* 362 * Get the last inode value, see if there's nothing to do. 363 */ 364 lastino = *lastinop; --- 19 unchanged lines hidden (view full) --- 384 return -ENOMEM; 385 386 nirbuf = irbsize / sizeof(*irbuf); 387 388 /* 389 * Loop over the allocation groups, starting from the last 390 * inode returned; 0 means start of the allocation group. 391 */ |
391 rval = 0; | |
392 while (agno < mp->m_sb.sb_agcount) { 393 struct xfs_inobt_rec_incore *irbp = irbuf; 394 struct xfs_inobt_rec_incore *irbufend = irbuf + nirbuf; 395 bool end_of_ag = false; 396 int icount = 0; 397 int stat; 398 399 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); --- 86 unchanged lines hidden (view full) --- 486 irbufend = irbp; 487 for (irbp = irbuf; 488 irbp < irbufend && ac.ac_ubleft >= statstruct_size; 489 irbp++) { 490 error = xfs_bulkstat_ag_ichunk(mp, agno, irbp, 491 formatter, statstruct_size, &ac, 492 &lastino); 493 if (error) | 392 while (agno < mp->m_sb.sb_agcount) { 393 struct xfs_inobt_rec_incore *irbp = irbuf; 394 struct xfs_inobt_rec_incore *irbufend = irbuf + nirbuf; 395 bool end_of_ag = false; 396 int icount = 0; 397 int stat; 398 399 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); --- 86 unchanged lines hidden (view full) --- 486 irbufend = irbp; 487 for (irbp = irbuf; 488 irbp < irbufend && ac.ac_ubleft >= statstruct_size; 489 irbp++) { 490 error = xfs_bulkstat_ag_ichunk(mp, agno, irbp, 491 formatter, statstruct_size, &ac, 492 &lastino); 493 if (error) |
494 rval = error; | 494 break; |
495 496 cond_resched(); 497 } 498 | 495 496 cond_resched(); 497 } 498 |
499 /* If we've run out of space, we are done */ 500 if (ac.ac_ubleft < statstruct_size) | 499 /* 500 * If we've run out of space or had a formatting error, we 501 * are now done 502 */ 503 if (ac.ac_ubleft < statstruct_size || error) |
501 break; 502 503 if (end_of_ag) { 504 agno++; 505 agino = 0; 506 } else 507 agino = XFS_INO_TO_AGINO(mp, lastino); 508 } 509 /* 510 * Done, we're either out of filesystem or space to put the data. 511 */ 512 kmem_free(irbuf); 513 *ubcountp = ac.ac_ubelem; | 504 break; 505 506 if (end_of_ag) { 507 agno++; 508 agino = 0; 509 } else 510 agino = XFS_INO_TO_AGINO(mp, lastino); 511 } 512 /* 513 * Done, we're either out of filesystem or space to put the data. 514 */ 515 kmem_free(irbuf); 516 *ubcountp = ac.ac_ubelem; |
517 |
|
514 /* | 518 /* |
515 * Found some inodes, return them now and return the error next time. | 519 * We found some inodes, so clear the error status and return them. 520 * The lastino pointer will point directly at the inode that triggered 521 * any error that occurred, so on the next call the error will be 522 * triggered again and propagated to userspace as there will be no 523 * formatted inodes in the buffer. |
516 */ 517 if (ac.ac_ubelem) | 524 */ 525 if (ac.ac_ubelem) |
518 rval = 0; | 526 error = 0; 527 |
519 if (agno >= mp->m_sb.sb_agcount) { 520 /* 521 * If we ran out of filesystem, mark lastino as off 522 * the end of the filesystem, so the next call 523 * will return immediately. 524 */ 525 *lastinop = (xfs_ino_t)XFS_AGINO_TO_INO(mp, agno, 0); 526 *done = 1; 527 } else 528 *lastinop = (xfs_ino_t)lastino; 529 | 528 if (agno >= mp->m_sb.sb_agcount) { 529 /* 530 * If we ran out of filesystem, mark lastino as off 531 * the end of the filesystem, so the next call 532 * will return immediately. 533 */ 534 *lastinop = (xfs_ino_t)XFS_AGINO_TO_INO(mp, agno, 0); 535 *done = 1; 536 } else 537 *lastinop = (xfs_ino_t)lastino; 538 |
530 return rval; | 539 return error; |
531} 532 533int 534xfs_inumbers_fmt( 535 void __user *ubuffer, /* buffer to write to */ 536 const struct xfs_inogrp *buffer, /* buffer to read from */ 537 long count, /* # of elements to read */ 538 long *written) /* # of bytes written */ --- 114 unchanged lines hidden --- | 540} 541 542int 543xfs_inumbers_fmt( 544 void __user *ubuffer, /* buffer to write to */ 545 const struct xfs_inogrp *buffer, /* buffer to read from */ 546 long count, /* # of elements to read */ 547 long *written) /* # of bytes written */ --- 114 unchanged lines hidden --- |