diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-16 22:19:33 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-16 22:19:33 -0400 |
| commit | 84588e7a5d8220446d677d7b909a20ee7a4496b9 (patch) | |
| tree | 5633f76cba4788cb2b073ac0c0f93541c267e7ee /include/linux | |
| parent | a39ef1a7c6093bbd4e0a8197350b99cd635e5446 (diff) | |
| parent | 3adc12e9648291149a1e3f354d0ad158fc2571e7 (diff) | |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull quota and udf updates from Jan Kara:
"The pull contains quota changes which complete unification of XFS and
VFS quota interfaces (so tools can use either interface to manipulate
any filesystem). There's also a patch to support project quotas in
VFS quota subsystem from Li Xi.
Finally there's a bunch of UDF fixes and cleanups and tiny cleanup in
reiserfs & ext3"
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: (21 commits)
udf: Update ctime and mtime when directory is modified
udf: return correct errno for udf_update_inode()
ext3: Remove useless condition in if statement.
vfs: Add general support to enforce project quota limits
reiserfs: fix __RASSERT format string
udf: use int for allocated blocks instead of sector_t
udf: remove redundant buffer_head.h includes
udf: remove else after return in __load_block_bitmap()
udf: remove unused variable in udf_table_free_blocks()
quota: Fix maximum quota limit settings
quota: reorder flags in quota state
quota: paranoia: check quota tree root
quota: optimize i_dquot access
quota: Hook up Q_XSETQLIM for id 0 to ->set_info
xfs: Add support for Q_SETINFO
quota: Make ->set_info use structure with neccesary info to VFS and XFS
quota: Remove ->get_xstate and ->get_xstatev callbacks
gfs2: Convert to using ->get_state callback
xfs: Convert to using ->get_state callback
quota: Wire up Q_GETXSTATE and Q_GETXSTATV calls to work with ->get_state
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/quota.h | 90 | ||||
| -rw-r--r-- | include/linux/quotaops.h | 14 |
2 files changed, 82 insertions, 22 deletions
diff --git a/include/linux/quota.h b/include/linux/quota.h index d534e8ed308a..b2505acfd3c0 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
| @@ -50,6 +50,7 @@ | |||
| 50 | 50 | ||
| 51 | #undef USRQUOTA | 51 | #undef USRQUOTA |
| 52 | #undef GRPQUOTA | 52 | #undef GRPQUOTA |
| 53 | #undef PRJQUOTA | ||
| 53 | enum quota_type { | 54 | enum quota_type { |
| 54 | USRQUOTA = 0, /* element used for user quotas */ | 55 | USRQUOTA = 0, /* element used for user quotas */ |
| 55 | GRPQUOTA = 1, /* element used for group quotas */ | 56 | GRPQUOTA = 1, /* element used for group quotas */ |
| @@ -319,6 +320,7 @@ struct dquot_operations { | |||
| 319 | /* get reserved quota for delayed alloc, value returned is managed by | 320 | /* get reserved quota for delayed alloc, value returned is managed by |
| 320 | * quota code only */ | 321 | * quota code only */ |
| 321 | qsize_t *(*get_reserved_space) (struct inode *); | 322 | qsize_t *(*get_reserved_space) (struct inode *); |
| 323 | int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */ | ||
| 322 | }; | 324 | }; |
| 323 | 325 | ||
| 324 | struct path; | 326 | struct path; |
| @@ -344,7 +346,10 @@ struct qc_dqblk { | |||
| 344 | int d_rt_spc_warns; /* # warnings issued wrt RT space */ | 346 | int d_rt_spc_warns; /* # warnings issued wrt RT space */ |
| 345 | }; | 347 | }; |
| 346 | 348 | ||
| 347 | /* Field specifiers for ->set_dqblk() in struct qc_dqblk */ | 349 | /* |
| 350 | * Field specifiers for ->set_dqblk() in struct qc_dqblk and also for | ||
| 351 | * ->set_info() in struct qc_info | ||
| 352 | */ | ||
| 348 | #define QC_INO_SOFT (1<<0) | 353 | #define QC_INO_SOFT (1<<0) |
| 349 | #define QC_INO_HARD (1<<1) | 354 | #define QC_INO_HARD (1<<1) |
| 350 | #define QC_SPC_SOFT (1<<2) | 355 | #define QC_SPC_SOFT (1<<2) |
| @@ -365,6 +370,51 @@ struct qc_dqblk { | |||
| 365 | #define QC_INO_COUNT (1<<13) | 370 | #define QC_INO_COUNT (1<<13) |
| 366 | #define QC_RT_SPACE (1<<14) | 371 | #define QC_RT_SPACE (1<<14) |
| 367 | #define QC_ACCT_MASK (QC_SPACE | QC_INO_COUNT | QC_RT_SPACE) | 372 | #define QC_ACCT_MASK (QC_SPACE | QC_INO_COUNT | QC_RT_SPACE) |
| 373 | #define QC_FLAGS (1<<15) | ||
| 374 | |||
| 375 | #define QCI_SYSFILE (1 << 0) /* Quota file is hidden from userspace */ | ||
| 376 | #define QCI_ROOT_SQUASH (1 << 1) /* Root squash turned on */ | ||
| 377 | #define QCI_ACCT_ENABLED (1 << 2) /* Quota accounting enabled */ | ||
| 378 | #define QCI_LIMITS_ENFORCED (1 << 3) /* Quota limits enforced */ | ||
| 379 | |||
| 380 | /* Structures for communicating via ->get_state */ | ||
| 381 | struct qc_type_state { | ||
| 382 | unsigned int flags; /* Flags QCI_* */ | ||
| 383 | unsigned int spc_timelimit; /* Time after which space softlimit is | ||
| 384 | * enforced */ | ||
| 385 | unsigned int ino_timelimit; /* Ditto for inode softlimit */ | ||
| 386 | unsigned int rt_spc_timelimit; /* Ditto for real-time space */ | ||
| 387 | unsigned int spc_warnlimit; /* Limit for number of space warnings */ | ||
| 388 | unsigned int ino_warnlimit; /* Ditto for inodes */ | ||
| 389 | unsigned int rt_spc_warnlimit; /* Ditto for real-time space */ | ||
| 390 | unsigned long long ino; /* Inode number of quota file */ | ||
| 391 | blkcnt_t blocks; /* Number of 512-byte blocks in the file */ | ||
| 392 | blkcnt_t nextents; /* Number of extents in the file */ | ||
| 393 | }; | ||
| 394 | |||
| 395 | struct qc_state { | ||
| 396 | unsigned int s_incoredqs; /* Number of dquots in core */ | ||
| 397 | /* | ||
| 398 | * Per quota type information. The array should really have | ||
| 399 | * max(MAXQUOTAS, XQM_MAXQUOTAS) entries. BUILD_BUG_ON in | ||
| 400 | * quota_getinfo() makes sure XQM_MAXQUOTAS is large enough. Once VFS | ||
| 401 | * supports project quotas, this can be changed to MAXQUOTAS | ||
| 402 | */ | ||
| 403 | struct qc_type_state s_state[XQM_MAXQUOTAS]; | ||
| 404 | }; | ||
| 405 | |||
| 406 | /* Structure for communicating via ->set_info */ | ||
| 407 | struct qc_info { | ||
| 408 | int i_fieldmask; /* mask of fields to change in ->set_info() */ | ||
| 409 | unsigned int i_flags; /* Flags QCI_* */ | ||
| 410 | unsigned int i_spc_timelimit; /* Time after which space softlimit is | ||
| 411 | * enforced */ | ||
| 412 | unsigned int i_ino_timelimit; /* Ditto for inode softlimit */ | ||
| 413 | unsigned int i_rt_spc_timelimit;/* Ditto for real-time space */ | ||
| 414 | unsigned int i_spc_warnlimit; /* Limit for number of space warnings */ | ||
| 415 | unsigned int i_ino_warnlimit; /* Limit for number of inode warnings */ | ||
| 416 | unsigned int i_rt_spc_warnlimit; /* Ditto for real-time space */ | ||
| 417 | }; | ||
| 368 | 418 | ||
| 369 | /* Operations handling requests from userspace */ | 419 | /* Operations handling requests from userspace */ |
| 370 | struct quotactl_ops { | 420 | struct quotactl_ops { |
| @@ -373,12 +423,10 @@ struct quotactl_ops { | |||
| 373 | int (*quota_enable)(struct super_block *, unsigned int); | 423 | int (*quota_enable)(struct super_block *, unsigned int); |
| 374 | int (*quota_disable)(struct super_block *, unsigned int); | 424 | int (*quota_disable)(struct super_block *, unsigned int); |
| 375 | int (*quota_sync)(struct super_block *, int); | 425 | int (*quota_sync)(struct super_block *, int); |
| 376 | int (*get_info)(struct super_block *, int, struct if_dqinfo *); | 426 | int (*set_info)(struct super_block *, int, struct qc_info *); |
| 377 | int (*set_info)(struct super_block *, int, struct if_dqinfo *); | ||
| 378 | int (*get_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *); | 427 | int (*get_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *); |
| 379 | int (*set_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *); | 428 | int (*set_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *); |
| 380 | int (*get_xstate)(struct super_block *, struct fs_quota_stat *); | 429 | int (*get_state)(struct super_block *, struct qc_state *); |
| 381 | int (*get_xstatev)(struct super_block *, struct fs_quota_statv *); | ||
| 382 | int (*rm_xquota)(struct super_block *, unsigned int); | 430 | int (*rm_xquota)(struct super_block *, unsigned int); |
| 383 | }; | 431 | }; |
| 384 | 432 | ||
| @@ -389,7 +437,19 @@ struct quota_format_type { | |||
| 389 | struct quota_format_type *qf_next; | 437 | struct quota_format_type *qf_next; |
| 390 | }; | 438 | }; |
| 391 | 439 | ||
| 392 | /* Quota state flags - they actually come in two flavors - for users and groups */ | 440 | /** |
| 441 | * Quota state flags - they actually come in two flavors - for users and groups. | ||
| 442 | * | ||
| 443 | * Actual typed flags layout: | ||
| 444 | * USRQUOTA GRPQUOTA | ||
| 445 | * DQUOT_USAGE_ENABLED 0x0001 0x0002 | ||
| 446 | * DQUOT_LIMITS_ENABLED 0x0004 0x0008 | ||
| 447 | * DQUOT_SUSPENDED 0x0010 0x0020 | ||
| 448 | * | ||
| 449 | * Following bits are used for non-typed flags: | ||
| 450 | * DQUOT_QUOTA_SYS_FILE 0x0040 | ||
| 451 | * DQUOT_NEGATIVE_USAGE 0x0080 | ||
| 452 | */ | ||
| 393 | enum { | 453 | enum { |
| 394 | _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */ | 454 | _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */ |
| 395 | _DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */ | 455 | _DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */ |
| @@ -398,9 +458,9 @@ enum { | |||
| 398 | * memory to turn them on */ | 458 | * memory to turn them on */ |
| 399 | _DQUOT_STATE_FLAGS | 459 | _DQUOT_STATE_FLAGS |
| 400 | }; | 460 | }; |
| 401 | #define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED) | 461 | #define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED * MAXQUOTAS) |
| 402 | #define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED) | 462 | #define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED * MAXQUOTAS) |
| 403 | #define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED) | 463 | #define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED * MAXQUOTAS) |
| 404 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ | 464 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ |
| 405 | DQUOT_SUSPENDED) | 465 | DQUOT_SUSPENDED) |
| 406 | /* Other quota flags */ | 466 | /* Other quota flags */ |
| @@ -414,15 +474,21 @@ enum { | |||
| 414 | */ | 474 | */ |
| 415 | #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1)) | 475 | #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1)) |
| 416 | /* Allow negative quota usage */ | 476 | /* Allow negative quota usage */ |
| 417 | |||
| 418 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) | 477 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) |
| 419 | { | 478 | { |
| 420 | return flags << _DQUOT_STATE_FLAGS * type; | 479 | return flags << type; |
| 421 | } | 480 | } |
| 422 | 481 | ||
| 423 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) | 482 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) |
| 424 | { | 483 | { |
| 425 | return (flags >> _DQUOT_STATE_FLAGS * type) & DQUOT_STATE_FLAGS; | 484 | return (flags >> type) & DQUOT_STATE_FLAGS; |
| 485 | } | ||
| 486 | |||
| 487 | /* Bitmap of quota types where flag is set in flags */ | ||
| 488 | static __always_inline unsigned dquot_state_types(unsigned flags, unsigned flag) | ||
| 489 | { | ||
| 490 | BUILD_BUG_ON_NOT_POWER_OF_2(flag); | ||
| 491 | return (flags / flag) & ((1 << MAXQUOTAS) - 1); | ||
| 426 | } | 492 | } |
| 427 | 493 | ||
| 428 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE | 494 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE |
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index df73258cca47..77ca6601ff25 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
| @@ -95,8 +95,8 @@ int dquot_quota_on_mount(struct super_block *sb, char *qf_name, | |||
| 95 | int dquot_quota_off(struct super_block *sb, int type); | 95 | int dquot_quota_off(struct super_block *sb, int type); |
| 96 | int dquot_writeback_dquots(struct super_block *sb, int type); | 96 | int dquot_writeback_dquots(struct super_block *sb, int type); |
| 97 | int dquot_quota_sync(struct super_block *sb, int type); | 97 | int dquot_quota_sync(struct super_block *sb, int type); |
| 98 | int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 98 | int dquot_get_state(struct super_block *sb, struct qc_state *state); |
| 99 | int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 99 | int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii); |
| 100 | int dquot_get_dqblk(struct super_block *sb, struct kqid id, | 100 | int dquot_get_dqblk(struct super_block *sb, struct kqid id, |
| 101 | struct qc_dqblk *di); | 101 | struct qc_dqblk *di); |
| 102 | int dquot_set_dqblk(struct super_block *sb, struct kqid id, | 102 | int dquot_set_dqblk(struct super_block *sb, struct kqid id, |
| @@ -134,10 +134,7 @@ static inline bool sb_has_quota_suspended(struct super_block *sb, int type) | |||
| 134 | 134 | ||
| 135 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) | 135 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) |
| 136 | { | 136 | { |
| 137 | unsigned type, tmsk = 0; | 137 | return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_SUSPENDED); |
| 138 | for (type = 0; type < MAXQUOTAS; type++) | ||
| 139 | tmsk |= sb_has_quota_suspended(sb, type) << type; | ||
| 140 | return tmsk; | ||
| 141 | } | 138 | } |
| 142 | 139 | ||
| 143 | /* Does kernel know about any quota information for given sb + type? */ | 140 | /* Does kernel know about any quota information for given sb + type? */ |
| @@ -149,10 +146,7 @@ static inline bool sb_has_quota_loaded(struct super_block *sb, int type) | |||
| 149 | 146 | ||
| 150 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) | 147 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) |
| 151 | { | 148 | { |
| 152 | unsigned type, tmsk = 0; | 149 | return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_USAGE_ENABLED); |
| 153 | for (type = 0; type < MAXQUOTAS; type++) | ||
| 154 | tmsk |= sb_has_quota_loaded(sb, type) << type; | ||
| 155 | return tmsk; | ||
| 156 | } | 150 | } |
| 157 | 151 | ||
| 158 | static inline bool sb_has_quota_active(struct super_block *sb, int type) | 152 | static inline bool sb_has_quota_active(struct super_block *sb, int type) |
