2 * quota.c - NTFS kernel quota ($Quota) handling. Part of the Linux-NTFS
5 * Copyright (c) 2004 Anton Altaparmakov
7 * This program/include file is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program/include file is distributed in the hope that it will be
13 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program (in the main directory of the Linux-NTFS
19 * distribution in the file COPYING); if not, write to the Free Software
20 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 * ntfs_mark_quotas_out_of_date - mark the quotas out of date on an ntfs volume
32 * @vol: ntfs volume on which to mark the quotas out of date
34 * Mark the quotas out of date on the ntfs volume @vol and return TRUE on
35 * success and FALSE on error.
37 BOOL
ntfs_mark_quotas_out_of_date(ntfs_volume
*vol
)
39 ntfs_index_context
*ictx
;
40 QUOTA_CONTROL_ENTRY
*qce
;
41 const le32 qid
= QUOTA_DEFAULTS_ID
;
44 ntfs_debug("Entering.");
45 if (NVolQuotaOutOfDate(vol
))
47 if (!vol
->quota_ino
|| !vol
->quota_q_ino
) {
48 ntfs_error(vol
->sb
, "Quota inodes are not open.");
51 down(&vol
->quota_q_ino
->i_sem
);
52 ictx
= ntfs_index_ctx_get(NTFS_I(vol
->quota_q_ino
));
54 ntfs_error(vol
->sb
, "Failed to get index context.");
57 err
= ntfs_index_lookup(&qid
, sizeof(qid
), ictx
);
60 ntfs_error(vol
->sb
, "Quota defaults entry is not "
63 ntfs_error(vol
->sb
, "Lookup of quota defaults entry "
67 if (ictx
->data_len
< offsetof(QUOTA_CONTROL_ENTRY
, sid
)) {
68 ntfs_error(vol
->sb
, "Quota defaults entry size is invalid. "
72 qce
= (QUOTA_CONTROL_ENTRY
*)ictx
->data
;
73 if (le32_to_cpu(qce
->version
) != QUOTA_VERSION
) {
74 ntfs_error(vol
->sb
, "Quota defaults entry version 0x%x is not "
75 "supported.", le32_to_cpu(qce
->version
));
78 ntfs_debug("Quota defaults flags = 0x%x.", le32_to_cpu(qce
->flags
));
79 /* If quotas are already marked out of date, no need to do anything. */
80 if (qce
->flags
& QUOTA_FLAG_OUT_OF_DATE
)
83 * If quota tracking is neither requested, nor enabled and there are no
84 * pending deletes, no need to mark the quotas out of date.
86 if (!(qce
->flags
& (QUOTA_FLAG_TRACKING_ENABLED
|
87 QUOTA_FLAG_TRACKING_REQUESTED
|
88 QUOTA_FLAG_PENDING_DELETES
)))
91 * Set the QUOTA_FLAG_OUT_OF_DATE bit thus marking quotas out of date.
92 * This is verified on WinXP to be sufficient to cause windows to
93 * rescan the volume on boot and update all quota entries.
95 qce
->flags
|= QUOTA_FLAG_OUT_OF_DATE
;
96 /* Ensure the modified flags are written to disk. */
97 ntfs_index_entry_flush_dcache_page(ictx
);
98 ntfs_index_entry_mark_dirty(ictx
);
100 ntfs_index_ctx_put(ictx
);
101 up(&vol
->quota_q_ino
->i_sem
);
103 * We set the flag so we do not try to mark the quotas out of date
106 NVolSetQuotaOutOfDate(vol
);
112 ntfs_index_ctx_put(ictx
);
113 up(&vol
->quota_q_ino
->i_sem
);