diff options
author | Nathan Scott <nathans@sgi.com> | 2006-06-09 00:59:13 -0400 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-06-09 00:59:13 -0400 |
commit | 59c1b082f5fff8269565039600a2ef18d48649b5 (patch) | |
tree | 28093cd9a1b61267d76edef992a91e7cecf40b5e /fs/xfs | |
parent | e109007461cddfc80a908f0b015f4eeb485e1d85 (diff) |
[XFS] Make the pflags test/set wrappers more legible for us mere humans.
SGI-PV: 953338
SGI-Modid: xfs-linux-melb:xfs-kern:26099a
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/linux-2.6/kmem.h | 38 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_aops.c | 4 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_linux.h | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_trans.c | 25 |
4 files changed, 24 insertions, 57 deletions
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h index 2cfd33d4d8aa..939bd84bc7ee 100644 --- a/fs/xfs/linux-2.6/kmem.h +++ b/fs/xfs/linux-2.6/kmem.h | |||
@@ -23,42 +23,6 @@ | |||
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * Process flags handling | ||
27 | */ | ||
28 | |||
29 | #define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO) | ||
30 | #define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS) | ||
31 | |||
32 | #define PFLAGS_SET_NOIO() do { \ | ||
33 | current->flags |= PF_NOIO; \ | ||
34 | } while (0) | ||
35 | |||
36 | #define PFLAGS_CLEAR_NOIO() do { \ | ||
37 | current->flags &= ~PF_NOIO; \ | ||
38 | } while (0) | ||
39 | |||
40 | /* these could be nested, so we save state */ | ||
41 | #define PFLAGS_SET_FSTRANS(STATEP) do { \ | ||
42 | *(STATEP) = current->flags; \ | ||
43 | current->flags |= PF_FSTRANS; \ | ||
44 | } while (0) | ||
45 | |||
46 | #define PFLAGS_CLEAR_FSTRANS(STATEP) do { \ | ||
47 | *(STATEP) = current->flags; \ | ||
48 | current->flags &= ~PF_FSTRANS; \ | ||
49 | } while (0) | ||
50 | |||
51 | /* Restore the PF_FSTRANS state to what was saved in STATEP */ | ||
52 | #define PFLAGS_RESTORE_FSTRANS(STATEP) do { \ | ||
53 | current->flags = ((current->flags & ~PF_FSTRANS) | \ | ||
54 | (*(STATEP) & PF_FSTRANS)); \ | ||
55 | } while (0) | ||
56 | |||
57 | #define PFLAGS_DUP(OSTATEP, NSTATEP) do { \ | ||
58 | *(NSTATEP) = *(OSTATEP); \ | ||
59 | } while (0) | ||
60 | |||
61 | /* | ||
62 | * General memory allocation interfaces | 26 | * General memory allocation interfaces |
63 | */ | 27 | */ |
64 | 28 | ||
@@ -83,7 +47,7 @@ kmem_flags_convert(unsigned int __nocast flags) | |||
83 | lflags = GFP_ATOMIC | __GFP_NOWARN; | 47 | lflags = GFP_ATOMIC | __GFP_NOWARN; |
84 | } else { | 48 | } else { |
85 | lflags = GFP_KERNEL | __GFP_NOWARN; | 49 | lflags = GFP_KERNEL | __GFP_NOWARN; |
86 | if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) | 50 | if ((current->flags & PF_FSTRANS) || (flags & KM_NOFS)) |
87 | lflags &= ~__GFP_FS; | 51 | lflags &= ~__GFP_FS; |
88 | } | 52 | } |
89 | return lflags; | 53 | return lflags; |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 1fcdc0abda6e..5835e699a7fc 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
@@ -1126,7 +1126,7 @@ xfs_vm_writepage( | |||
1126 | * then mark the page dirty again and leave the page | 1126 | * then mark the page dirty again and leave the page |
1127 | * as is. | 1127 | * as is. |
1128 | */ | 1128 | */ |
1129 | if (PFLAGS_TEST_FSTRANS() && need_trans) | 1129 | if (current_test_flags(PF_FSTRANS) && need_trans) |
1130 | goto out_fail; | 1130 | goto out_fail; |
1131 | 1131 | ||
1132 | /* | 1132 | /* |
@@ -1203,7 +1203,7 @@ xfs_vm_releasepage( | |||
1203 | /* If we are already inside a transaction or the thread cannot | 1203 | /* If we are already inside a transaction or the thread cannot |
1204 | * do I/O, we cannot release this page. | 1204 | * do I/O, we cannot release this page. |
1205 | */ | 1205 | */ |
1206 | if (PFLAGS_TEST_FSTRANS()) | 1206 | if (current_test_flags(PF_FSTRANS)) |
1207 | return 0; | 1207 | return 0; |
1208 | 1208 | ||
1209 | /* | 1209 | /* |
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index 7d15cb910275..e92853954111 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
@@ -136,13 +136,19 @@ BUFFER_FNS(PrivateStart, unwritten); | |||
136 | #define xfs_rotorstep xfs_params.rotorstep.val | 136 | #define xfs_rotorstep xfs_params.rotorstep.val |
137 | #define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val | 137 | #define xfs_inherit_nodefrag xfs_params.inherit_nodfrg.val |
138 | 138 | ||
139 | #ifndef raw_smp_processor_id | 139 | #define current_cpu() (raw_smp_processor_id()) |
140 | #define raw_smp_processor_id() smp_processor_id() | ||
141 | #endif | ||
142 | #define current_cpu() raw_smp_processor_id() | ||
143 | #define current_pid() (current->pid) | 140 | #define current_pid() (current->pid) |
144 | #define current_fsuid(cred) (current->fsuid) | 141 | #define current_fsuid(cred) (current->fsuid) |
145 | #define current_fsgid(cred) (current->fsgid) | 142 | #define current_fsgid(cred) (current->fsgid) |
143 | #define current_set_flags(f) (current->flags |= (f)) | ||
144 | #define current_test_flags(f) (current->flags & (f)) | ||
145 | #define current_clear_flags(f) (current->flags & ~(f)) | ||
146 | #define current_set_flags_nested(sp, f) \ | ||
147 | (*(sp) = current->flags, current->flags |= (f)) | ||
148 | #define current_clear_flags_nested(sp, f) \ | ||
149 | (*(sp) = current->flags, current->flags &= ~(f)) | ||
150 | #define current_restore_flags_nested(sp, f) \ | ||
151 | (current->flags = ((current->flags & ~(f)) | (*(sp) & (f)))) | ||
146 | 152 | ||
147 | #define NBPP PAGE_SIZE | 153 | #define NBPP PAGE_SIZE |
148 | #define DPPSHFT (PAGE_SHIFT - 9) | 154 | #define DPPSHFT (PAGE_SHIFT - 9) |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index c05da5871a51..7a99ed3b187f 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -303,7 +303,7 @@ xfs_trans_dup( | |||
303 | tp->t_blk_res = tp->t_blk_res_used; | 303 | tp->t_blk_res = tp->t_blk_res_used; |
304 | ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; | 304 | ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; |
305 | tp->t_rtx_res = tp->t_rtx_res_used; | 305 | tp->t_rtx_res = tp->t_rtx_res_used; |
306 | PFLAGS_DUP(&tp->t_pflags, &ntp->t_pflags); | 306 | ntp->t_pflags = tp->t_pflags; |
307 | 307 | ||
308 | XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); | 308 | XFS_TRANS_DUP_DQINFO(tp->t_mountp, tp, ntp); |
309 | 309 | ||
@@ -335,14 +335,11 @@ xfs_trans_reserve( | |||
335 | uint logcount) | 335 | uint logcount) |
336 | { | 336 | { |
337 | int log_flags; | 337 | int log_flags; |
338 | int error; | 338 | int error = 0; |
339 | int rsvd; | 339 | int rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; |
340 | |||
341 | error = 0; | ||
342 | rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; | ||
343 | 340 | ||
344 | /* Mark this thread as being in a transaction */ | 341 | /* Mark this thread as being in a transaction */ |
345 | PFLAGS_SET_FSTRANS(&tp->t_pflags); | 342 | current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); |
346 | 343 | ||
347 | /* | 344 | /* |
348 | * Attempt to reserve the needed disk blocks by decrementing | 345 | * Attempt to reserve the needed disk blocks by decrementing |
@@ -353,7 +350,7 @@ xfs_trans_reserve( | |||
353 | error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, | 350 | error = xfs_mod_incore_sb(tp->t_mountp, XFS_SBS_FDBLOCKS, |
354 | -blocks, rsvd); | 351 | -blocks, rsvd); |
355 | if (error != 0) { | 352 | if (error != 0) { |
356 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 353 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
357 | return (XFS_ERROR(ENOSPC)); | 354 | return (XFS_ERROR(ENOSPC)); |
358 | } | 355 | } |
359 | tp->t_blk_res += blocks; | 356 | tp->t_blk_res += blocks; |
@@ -426,9 +423,9 @@ undo_blocks: | |||
426 | tp->t_blk_res = 0; | 423 | tp->t_blk_res = 0; |
427 | } | 424 | } |
428 | 425 | ||
429 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 426 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
430 | 427 | ||
431 | return (error); | 428 | return error; |
432 | } | 429 | } |
433 | 430 | ||
434 | 431 | ||
@@ -819,7 +816,7 @@ shut_us_down: | |||
819 | if (commit_lsn == -1 && !shutdown) | 816 | if (commit_lsn == -1 && !shutdown) |
820 | shutdown = XFS_ERROR(EIO); | 817 | shutdown = XFS_ERROR(EIO); |
821 | } | 818 | } |
822 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 819 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
823 | xfs_trans_free_items(tp, shutdown? XFS_TRANS_ABORT : 0); | 820 | xfs_trans_free_items(tp, shutdown? XFS_TRANS_ABORT : 0); |
824 | xfs_trans_free_busy(tp); | 821 | xfs_trans_free_busy(tp); |
825 | xfs_trans_free(tp); | 822 | xfs_trans_free(tp); |
@@ -884,7 +881,7 @@ shut_us_down: | |||
884 | * had pinned, clean up, free trans structure, and return error. | 881 | * had pinned, clean up, free trans structure, and return error. |
885 | */ | 882 | */ |
886 | if (error || commit_lsn == -1) { | 883 | if (error || commit_lsn == -1) { |
887 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 884 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
888 | xfs_trans_uncommit(tp, flags|XFS_TRANS_ABORT); | 885 | xfs_trans_uncommit(tp, flags|XFS_TRANS_ABORT); |
889 | return XFS_ERROR(EIO); | 886 | return XFS_ERROR(EIO); |
890 | } | 887 | } |
@@ -926,7 +923,7 @@ shut_us_down: | |||
926 | /* | 923 | /* |
927 | * Mark this thread as no longer being in a transaction | 924 | * Mark this thread as no longer being in a transaction |
928 | */ | 925 | */ |
929 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 926 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
930 | 927 | ||
931 | /* | 928 | /* |
932 | * Once all the items of the transaction have been copied | 929 | * Once all the items of the transaction have been copied |
@@ -1182,7 +1179,7 @@ xfs_trans_cancel( | |||
1182 | } | 1179 | } |
1183 | 1180 | ||
1184 | /* mark this thread as no longer being in a transaction */ | 1181 | /* mark this thread as no longer being in a transaction */ |
1185 | PFLAGS_RESTORE_FSTRANS(&tp->t_pflags); | 1182 | current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); |
1186 | 1183 | ||
1187 | xfs_trans_free_items(tp, flags); | 1184 | xfs_trans_free_items(tp, flags); |
1188 | xfs_trans_free_busy(tp); | 1185 | xfs_trans_free_busy(tp); |