diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-03-22 20:47:38 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-19 10:58:10 -0400 |
commit | e6b1f27370fc67ac9868b2dbe2c22bc26952900e (patch) | |
tree | 69485365ff6b9f22a56bcfc4814b27b45622d6e9 /fs/xfs/xfs_log.c | |
parent | 55b66332d0921146a914d5d75a7b870a65dc4938 (diff) |
xfs: clean up xlog_write_adv_cnt
Replace the awkward xlog_write_adv_cnt with an inline helper that makes
it more obvious that it's modifying it's paramters, and replace the use
of an integer type for "ptr" with a real void pointer. Also move
xlog_write_adv_cnt to xfs_log_priv.h as it will be used outside of
xfs_log.c in the delayed logging series.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r-- | fs/xfs/xfs_log.c | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 2e6f3b82e4b7..9edbd67b5a9d 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -44,11 +44,6 @@ | |||
44 | 44 | ||
45 | kmem_zone_t *xfs_log_ticket_zone; | 45 | kmem_zone_t *xfs_log_ticket_zone; |
46 | 46 | ||
47 | #define xlog_write_adv_cnt(ptr, len, off, bytes) \ | ||
48 | { (ptr) += (bytes); \ | ||
49 | (len) -= (bytes); \ | ||
50 | (off) += (bytes);} | ||
51 | |||
52 | /* Local miscellaneous function prototypes */ | 47 | /* Local miscellaneous function prototypes */ |
53 | STATIC int xlog_commit_record(struct log *log, struct xlog_ticket *ticket, | 48 | STATIC int xlog_commit_record(struct log *log, struct xlog_ticket *ticket, |
54 | xlog_in_core_t **, xfs_lsn_t *); | 49 | xlog_in_core_t **, xfs_lsn_t *); |
@@ -100,7 +95,7 @@ STATIC xlog_ticket_t *xlog_ticket_alloc(xlog_t *log, | |||
100 | uint flags); | 95 | uint flags); |
101 | 96 | ||
102 | #if defined(DEBUG) | 97 | #if defined(DEBUG) |
103 | STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr); | 98 | STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr); |
104 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); | 99 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); |
105 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, | 100 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, |
106 | int count, boolean_t syncing); | 101 | int count, boolean_t syncing); |
@@ -1683,11 +1678,9 @@ xlog_write_calc_vec_length( | |||
1683 | */ | 1678 | */ |
1684 | static int | 1679 | static int |
1685 | xlog_write_start_rec( | 1680 | xlog_write_start_rec( |
1686 | __psint_t ptr, | 1681 | struct xlog_op_header *ophdr, |
1687 | struct xlog_ticket *ticket) | 1682 | struct xlog_ticket *ticket) |
1688 | { | 1683 | { |
1689 | struct xlog_op_header *ophdr = (struct xlog_op_header *)ptr; | ||
1690 | |||
1691 | if (!(ticket->t_flags & XLOG_TIC_INITED)) | 1684 | if (!(ticket->t_flags & XLOG_TIC_INITED)) |
1692 | return 0; | 1685 | return 0; |
1693 | 1686 | ||
@@ -1705,12 +1698,10 @@ xlog_write_start_rec( | |||
1705 | static xlog_op_header_t * | 1698 | static xlog_op_header_t * |
1706 | xlog_write_setup_ophdr( | 1699 | xlog_write_setup_ophdr( |
1707 | struct log *log, | 1700 | struct log *log, |
1708 | __psint_t ptr, | 1701 | struct xlog_op_header *ophdr, |
1709 | struct xlog_ticket *ticket, | 1702 | struct xlog_ticket *ticket, |
1710 | uint flags) | 1703 | uint flags) |
1711 | { | 1704 | { |
1712 | struct xlog_op_header *ophdr = (struct xlog_op_header *)ptr; | ||
1713 | |||
1714 | ophdr->oh_tid = cpu_to_be32(ticket->t_tid); | 1705 | ophdr->oh_tid = cpu_to_be32(ticket->t_tid); |
1715 | ophdr->oh_clientid = ticket->t_clientid; | 1706 | ophdr->oh_clientid = ticket->t_clientid; |
1716 | ophdr->oh_res2 = 0; | 1707 | ophdr->oh_res2 = 0; |
@@ -1917,7 +1908,7 @@ xlog_write( | |||
1917 | lv = log_vector; | 1908 | lv = log_vector; |
1918 | vecp = lv->lv_iovecp; | 1909 | vecp = lv->lv_iovecp; |
1919 | while (lv && index < lv->lv_niovecs) { | 1910 | while (lv && index < lv->lv_niovecs) { |
1920 | __psint_t ptr; | 1911 | void *ptr; |
1921 | int log_offset; | 1912 | int log_offset; |
1922 | 1913 | ||
1923 | error = xlog_state_get_iclog_space(log, len, &iclog, ticket, | 1914 | error = xlog_state_get_iclog_space(log, len, &iclog, ticket, |
@@ -1926,7 +1917,7 @@ xlog_write( | |||
1926 | return error; | 1917 | return error; |
1927 | 1918 | ||
1928 | ASSERT(log_offset <= iclog->ic_size - 1); | 1919 | ASSERT(log_offset <= iclog->ic_size - 1); |
1929 | ptr = (__psint_t)((char *)iclog->ic_datap + log_offset); | 1920 | ptr = iclog->ic_datap + log_offset; |
1930 | 1921 | ||
1931 | /* start_lsn is the first lsn written to. That's all we need. */ | 1922 | /* start_lsn is the first lsn written to. That's all we need. */ |
1932 | if (!*start_lsn) | 1923 | if (!*start_lsn) |
@@ -1944,12 +1935,12 @@ xlog_write( | |||
1944 | int copy_off; | 1935 | int copy_off; |
1945 | 1936 | ||
1946 | ASSERT(reg->i_len % sizeof(__int32_t) == 0); | 1937 | ASSERT(reg->i_len % sizeof(__int32_t) == 0); |
1947 | ASSERT((__psint_t)ptr % sizeof(__int32_t) == 0); | 1938 | ASSERT((unsigned long)ptr % sizeof(__int32_t) == 0); |
1948 | 1939 | ||
1949 | start_rec_copy = xlog_write_start_rec(ptr, ticket); | 1940 | start_rec_copy = xlog_write_start_rec(ptr, ticket); |
1950 | if (start_rec_copy) { | 1941 | if (start_rec_copy) { |
1951 | record_cnt++; | 1942 | record_cnt++; |
1952 | xlog_write_adv_cnt(ptr, len, log_offset, | 1943 | xlog_write_adv_cnt(&ptr, &len, &log_offset, |
1953 | start_rec_copy); | 1944 | start_rec_copy); |
1954 | } | 1945 | } |
1955 | 1946 | ||
@@ -1957,7 +1948,7 @@ xlog_write( | |||
1957 | if (!ophdr) | 1948 | if (!ophdr) |
1958 | return XFS_ERROR(EIO); | 1949 | return XFS_ERROR(EIO); |
1959 | 1950 | ||
1960 | xlog_write_adv_cnt(ptr, len, log_offset, | 1951 | xlog_write_adv_cnt(&ptr, &len, &log_offset, |
1961 | sizeof(struct xlog_op_header)); | 1952 | sizeof(struct xlog_op_header)); |
1962 | 1953 | ||
1963 | len += xlog_write_setup_copy(ticket, ophdr, | 1954 | len += xlog_write_setup_copy(ticket, ophdr, |
@@ -1970,9 +1961,8 @@ xlog_write( | |||
1970 | 1961 | ||
1971 | /* copy region */ | 1962 | /* copy region */ |
1972 | ASSERT(copy_len >= 0); | 1963 | ASSERT(copy_len >= 0); |
1973 | memcpy((xfs_caddr_t)ptr, reg->i_addr + copy_off, | 1964 | memcpy(ptr, reg->i_addr + copy_off, copy_len); |
1974 | copy_len); | 1965 | xlog_write_adv_cnt(&ptr, &len, &log_offset, copy_len); |
1975 | xlog_write_adv_cnt(ptr, len, log_offset, copy_len); | ||
1976 | 1966 | ||
1977 | copy_len += start_rec_copy + sizeof(xlog_op_header_t); | 1967 | copy_len += start_rec_copy + sizeof(xlog_op_header_t); |
1978 | record_cnt++; | 1968 | record_cnt++; |
@@ -3454,20 +3444,22 @@ xlog_ticket_alloc( | |||
3454 | * part of the log in case we trash the log structure. | 3444 | * part of the log in case we trash the log structure. |
3455 | */ | 3445 | */ |
3456 | void | 3446 | void |
3457 | xlog_verify_dest_ptr(xlog_t *log, | 3447 | xlog_verify_dest_ptr( |
3458 | __psint_t ptr) | 3448 | struct log *log, |
3449 | char *ptr) | ||
3459 | { | 3450 | { |
3460 | int i; | 3451 | int i; |
3461 | int good_ptr = 0; | 3452 | int good_ptr = 0; |
3462 | 3453 | ||
3463 | for (i=0; i < log->l_iclog_bufs; i++) { | 3454 | for (i = 0; i < log->l_iclog_bufs; i++) { |
3464 | if (ptr >= (__psint_t)log->l_iclog_bak[i] && | 3455 | if (ptr >= log->l_iclog_bak[i] && |
3465 | ptr <= (__psint_t)log->l_iclog_bak[i]+log->l_iclog_size) | 3456 | ptr <= log->l_iclog_bak[i] + log->l_iclog_size) |
3466 | good_ptr++; | 3457 | good_ptr++; |
3467 | } | 3458 | } |
3468 | if (! good_ptr) | 3459 | |
3460 | if (!good_ptr) | ||
3469 | xlog_panic("xlog_verify_dest_ptr: invalid ptr"); | 3461 | xlog_panic("xlog_verify_dest_ptr: invalid ptr"); |
3470 | } /* xlog_verify_dest_ptr */ | 3462 | } |
3471 | 3463 | ||
3472 | STATIC void | 3464 | STATIC void |
3473 | xlog_verify_grant_head(xlog_t *log, int equals) | 3465 | xlog_verify_grant_head(xlog_t *log, int equals) |