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