diff options
Diffstat (limited to 'fs/xfs/xfs_sb.h')
-rw-r--r-- | fs/xfs/xfs_sb.h | 167 |
1 files changed, 87 insertions, 80 deletions
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h index 3f8cf1587f4c..1ed71916e4c9 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/xfs_sb.h | |||
@@ -79,6 +79,7 @@ struct xfs_mount; | |||
79 | #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ | 79 | #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ |
80 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 | 80 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 |
81 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ | 81 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ |
82 | #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */ | ||
82 | 83 | ||
83 | #define XFS_SB_VERSION2_OKREALFBITS \ | 84 | #define XFS_SB_VERSION2_OKREALFBITS \ |
84 | (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ | 85 | (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ |
@@ -296,30 +297,34 @@ typedef enum { | |||
296 | 297 | ||
297 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) | 298 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) |
298 | 299 | ||
299 | #ifdef __KERNEL__ | ||
300 | static inline int xfs_sb_good_version(xfs_sb_t *sbp) | 300 | static inline int xfs_sb_good_version(xfs_sb_t *sbp) |
301 | { | 301 | { |
302 | return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \ | 302 | /* We always support version 1-3 */ |
303 | (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \ | 303 | if (sbp->sb_versionnum >= XFS_SB_VERSION_1 && |
304 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 304 | sbp->sb_versionnum <= XFS_SB_VERSION_3) |
305 | !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ | 305 | return 1; |
306 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \ | 306 | |
307 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \ | 307 | /* We support version 4 if all feature bits are supported */ |
308 | (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN))); | 308 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) { |
309 | } | 309 | if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || |
310 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && | ||
311 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) | ||
312 | return 0; | ||
313 | |||
314 | #ifdef __KERNEL__ | ||
315 | if (sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN) | ||
316 | return 0; | ||
310 | #else | 317 | #else |
311 | static inline int xfs_sb_good_version(xfs_sb_t *sbp) | 318 | if ((sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) && |
312 | { | 319 | sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN) |
313 | return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \ | 320 | return 0; |
314 | (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \ | 321 | #endif |
315 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 322 | |
316 | !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \ | 323 | return 1; |
317 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \ | 324 | } |
318 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \ | 325 | |
319 | (!(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \ | 326 | return 0; |
320 | (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)))); | ||
321 | } | 327 | } |
322 | #endif /* __KERNEL__ */ | ||
323 | 328 | ||
324 | /* | 329 | /* |
325 | * Detect a mismatched features2 field. Older kernels read/wrote | 330 | * Detect a mismatched features2 field. Older kernels read/wrote |
@@ -332,123 +337,127 @@ static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp) | |||
332 | 337 | ||
333 | static inline unsigned xfs_sb_version_tonew(unsigned v) | 338 | static inline unsigned xfs_sb_version_tonew(unsigned v) |
334 | { | 339 | { |
335 | return ((((v) == XFS_SB_VERSION_1) ? \ | 340 | if (v == XFS_SB_VERSION_1) |
336 | 0 : \ | 341 | return XFS_SB_VERSION_4; |
337 | (((v) == XFS_SB_VERSION_2) ? \ | 342 | |
338 | XFS_SB_VERSION_ATTRBIT : \ | 343 | if (v == XFS_SB_VERSION_2) |
339 | (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \ | 344 | return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT; |
340 | XFS_SB_VERSION_4); | 345 | |
346 | return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT | | ||
347 | XFS_SB_VERSION_NLINKBIT; | ||
341 | } | 348 | } |
342 | 349 | ||
343 | static inline unsigned xfs_sb_version_toold(unsigned v) | 350 | static inline unsigned xfs_sb_version_toold(unsigned v) |
344 | { | 351 | { |
345 | return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \ | 352 | if (v & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) |
346 | 0 : \ | 353 | return 0; |
347 | (((v) & XFS_SB_VERSION_NLINKBIT) ? \ | 354 | if (v & XFS_SB_VERSION_NLINKBIT) |
348 | XFS_SB_VERSION_3 : \ | 355 | return XFS_SB_VERSION_3; |
349 | (((v) & XFS_SB_VERSION_ATTRBIT) ? \ | 356 | if (v & XFS_SB_VERSION_ATTRBIT) |
350 | XFS_SB_VERSION_2 : \ | 357 | return XFS_SB_VERSION_2; |
351 | XFS_SB_VERSION_1))); | 358 | return XFS_SB_VERSION_1; |
352 | } | 359 | } |
353 | 360 | ||
354 | static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp) | 361 | static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp) |
355 | { | 362 | { |
356 | return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \ | 363 | return sbp->sb_versionnum == XFS_SB_VERSION_2 || |
357 | ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ | 364 | sbp->sb_versionnum == XFS_SB_VERSION_3 || |
358 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 365 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
359 | ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); | 366 | (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); |
360 | } | 367 | } |
361 | 368 | ||
362 | static inline void xfs_sb_version_addattr(xfs_sb_t *sbp) | 369 | static inline void xfs_sb_version_addattr(xfs_sb_t *sbp) |
363 | { | 370 | { |
364 | (sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \ | 371 | if (sbp->sb_versionnum == XFS_SB_VERSION_1) |
365 | XFS_SB_VERSION_2 : \ | 372 | sbp->sb_versionnum = XFS_SB_VERSION_2; |
366 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \ | 373 | else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) |
367 | ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \ | 374 | sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; |
368 | (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT))); | 375 | else |
376 | sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT; | ||
369 | } | 377 | } |
370 | 378 | ||
371 | static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) | 379 | static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) |
372 | { | 380 | { |
373 | return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ | 381 | return sbp->sb_versionnum == XFS_SB_VERSION_3 || |
374 | ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 382 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
375 | ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); | 383 | (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); |
376 | } | 384 | } |
377 | 385 | ||
378 | static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp) | 386 | static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp) |
379 | { | 387 | { |
380 | (sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \ | 388 | if (sbp->sb_versionnum <= XFS_SB_VERSION_2) |
381 | XFS_SB_VERSION_3 : \ | 389 | sbp->sb_versionnum = XFS_SB_VERSION_3; |
382 | ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT)); | 390 | else |
391 | sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT; | ||
383 | } | 392 | } |
384 | 393 | ||
385 | static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) | 394 | static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) |
386 | { | 395 | { |
387 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 396 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
388 | ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT); | 397 | (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); |
389 | } | 398 | } |
390 | 399 | ||
391 | static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) | 400 | static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) |
392 | { | 401 | { |
393 | (sbp)->sb_versionnum = \ | 402 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) |
394 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \ | 403 | sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; |
395 | ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \ | 404 | else |
396 | (xfs_sb_version_tonew((sbp)->sb_versionnum) | \ | 405 | sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) | |
397 | XFS_SB_VERSION_QUOTABIT)); | 406 | XFS_SB_VERSION_QUOTABIT; |
398 | } | 407 | } |
399 | 408 | ||
400 | static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) | 409 | static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) |
401 | { | 410 | { |
402 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 411 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
403 | ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); | 412 | (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); |
404 | } | 413 | } |
405 | 414 | ||
406 | static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) | 415 | static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) |
407 | { | 416 | { |
408 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 417 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
409 | ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); | 418 | (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); |
410 | } | 419 | } |
411 | 420 | ||
412 | static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp) | 421 | static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp) |
413 | { | 422 | { |
414 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 423 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
415 | ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT); | 424 | (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT); |
416 | } | 425 | } |
417 | 426 | ||
418 | static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) | 427 | static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) |
419 | { | 428 | { |
420 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 429 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
421 | ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); | 430 | (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); |
422 | } | 431 | } |
423 | 432 | ||
424 | static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) | 433 | static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) |
425 | { | 434 | { |
426 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 435 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
427 | ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); | 436 | (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); |
428 | } | 437 | } |
429 | 438 | ||
430 | static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) | 439 | static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) |
431 | { | 440 | { |
432 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 441 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
433 | ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); | 442 | (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); |
434 | } | 443 | } |
435 | 444 | ||
436 | static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) | 445 | static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) |
437 | { | 446 | { |
438 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 447 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
439 | ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT); | 448 | (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); |
440 | } | 449 | } |
441 | 450 | ||
442 | static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) | 451 | static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) |
443 | { | 452 | { |
444 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 453 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
445 | (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); | 454 | (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); |
446 | } | 455 | } |
447 | 456 | ||
448 | static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) | 457 | static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) |
449 | { | 458 | { |
450 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ | 459 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
451 | ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); | 460 | (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); |
452 | } | 461 | } |
453 | 462 | ||
454 | /* | 463 | /* |
@@ -463,22 +472,20 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) | |||
463 | 472 | ||
464 | static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) | 473 | static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) |
465 | { | 474 | { |
466 | return (xfs_sb_version_hasmorebits(sbp) && \ | 475 | return xfs_sb_version_hasmorebits(sbp) && |
467 | ((sbp)->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); | 476 | (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT); |
468 | } | 477 | } |
469 | 478 | ||
470 | static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) | 479 | static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) |
471 | { | 480 | { |
472 | return (xfs_sb_version_hasmorebits(sbp)) && \ | 481 | return xfs_sb_version_hasmorebits(sbp) && |
473 | ((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); | 482 | (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); |
474 | } | 483 | } |
475 | 484 | ||
476 | static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) | 485 | static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) |
477 | { | 486 | { |
478 | ((sbp)->sb_versionnum = \ | 487 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; |
479 | ((sbp)->sb_versionnum | XFS_SB_VERSION_MOREBITSBIT), \ | 488 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; |
480 | ((sbp)->sb_features2 = \ | ||
481 | ((sbp)->sb_features2 | XFS_SB_VERSION2_ATTR2BIT))); | ||
482 | } | 489 | } |
483 | 490 | ||
484 | static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp) | 491 | static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp) |