2019-05-31 08:09:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2006-01-16 16:50:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
|
2008-01-28 17:20:10 +00:00
|
|
|
* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
|
2006-01-16 16:50:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LOPS_DOT_H__
|
|
|
|
#define __LOPS_DOT_H__
|
|
|
|
|
2006-09-05 14:39:21 +00:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include "incore.h"
|
|
|
|
|
2006-04-07 15:17:32 +00:00
|
|
|
extern const struct gfs2_log_operations *gfs2_log_ops[];
|
2019-08-28 20:21:34 +00:00
|
|
|
extern void gfs2_log_incr_head(struct gfs2_sbd *sdp);
|
|
|
|
extern u64 gfs2_log_bmap(struct gfs2_jdesc *jd, unsigned int lbn);
|
2021-01-21 15:10:26 +00:00
|
|
|
extern void gfs2_log_write(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
|
|
|
|
struct page *page, unsigned size, unsigned offset,
|
|
|
|
u64 blkno);
|
2019-05-02 19:17:40 +00:00
|
|
|
extern void gfs2_log_submit_bio(struct bio **biop, int opf);
|
2012-12-14 12:52:14 +00:00
|
|
|
extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
|
2019-05-02 19:17:40 +00:00
|
|
|
extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
|
|
|
|
struct gfs2_log_header_host *head, bool keep_cache);
|
[GFS2] assertion failure after writing to journaled file, umount
This patch passes all my nasty tests that were causing the code to
fail under one circumstance or another. Here is a complete summary
of all changes from today's git tree, in order of appearance:
1. There are now separate variables for metadata buffer accounting.
2. Variable sd_log_num_hdrs is no longer needed, since the header
accounting is taken care of by the reserve/refund sequence.
3. Fixed a tiny grammatical problem in a comment.
4. Added a new function "calc_reserved" to calculate the reserved
log space. This isn't entirely necessary, but it has two benefits:
First, it simplifies the gfs2_log_refund function greatly.
Second, it allows for easier debugging because I could sprinkle the
code with calls to this function to make sure the accounting is
proper (by adding asserts and printks) at strategic point of the code.
5. In log_pull_tail there apparently was a kludge to fix up the
accounting based on a "pull" parameter. The buffer accounting is
now done properly, so the kludge was removed.
6. File sync operations were making a call to gfs2_log_flush that
writes another journal header. Since that header was unplanned
for (reserved) by the reserve/refund sequence, the free space had
to be decremented so that when log_pull_tail gets called, the free
space is be adjusted properly. (Did I hear you call that a kludge?
well, maybe, but a lot more justifiable than the one I removed).
7. In the gfs2_log_shutdown code, it optionally syncs the log by
specifying the PULL parameter to log_write_header. I'm not sure
this is necessary anymore. It just seems to me there could be
cases where shutdown is called while there are outstanding log
buffers.
8. In the (data)buf_lo_before_commit functions, I changed some offset
values from being calculated on the fly to being constants. That
simplified some code and we might as well let the compiler do the
calculation once rather than redoing those cycles at run time.
9. This version has my rewritten databuf_lo_add function.
This version is much more like its predecessor, buf_lo_add, which
makes it easier to understand. Again, this might not be necessary,
but it seems as if this one works as well as the previous one,
maybe even better, so I decided to leave it in.
10. In databuf_lo_before_commit, a previous data corruption problem
was caused by going off the end of the buffer. The proper solution
is to have the proper limit in place, rather than stopping earlier.
(Thus my previous attempt to fix it is wrong).
If you don't wrap the buffer, you're stopping too early and that
causes more log buffer accounting problems.
11. In lops.h there are two new (previously mentioned) constants for
figuring out the data offset for the journal buffers.
12. There are also two new functions, buf_limit and databuf_limit to
calculate how many entries will fit in the buffer.
13. In function gfs2_meta_wipe, it needs to distinguish between pinned
metadata buffers and journaled data buffers for proper journal buffer
accounting. It can't use the JDATA gfs2_inode flag because it's
sometimes passed the "real" inode and sometimes the "metadata
inode" and the inode flags will be random bits in a metadata
gfs2_inode. It needs to base its decision on which was passed in.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2007-06-18 19:50:20 +00:00
|
|
|
static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
|
|
|
|
{
|
2020-12-05 12:21:50 +00:00
|
|
|
return sdp->sd_ldptrs;
|
[GFS2] assertion failure after writing to journaled file, umount
This patch passes all my nasty tests that were causing the code to
fail under one circumstance or another. Here is a complete summary
of all changes from today's git tree, in order of appearance:
1. There are now separate variables for metadata buffer accounting.
2. Variable sd_log_num_hdrs is no longer needed, since the header
accounting is taken care of by the reserve/refund sequence.
3. Fixed a tiny grammatical problem in a comment.
4. Added a new function "calc_reserved" to calculate the reserved
log space. This isn't entirely necessary, but it has two benefits:
First, it simplifies the gfs2_log_refund function greatly.
Second, it allows for easier debugging because I could sprinkle the
code with calls to this function to make sure the accounting is
proper (by adding asserts and printks) at strategic point of the code.
5. In log_pull_tail there apparently was a kludge to fix up the
accounting based on a "pull" parameter. The buffer accounting is
now done properly, so the kludge was removed.
6. File sync operations were making a call to gfs2_log_flush that
writes another journal header. Since that header was unplanned
for (reserved) by the reserve/refund sequence, the free space had
to be decremented so that when log_pull_tail gets called, the free
space is be adjusted properly. (Did I hear you call that a kludge?
well, maybe, but a lot more justifiable than the one I removed).
7. In the gfs2_log_shutdown code, it optionally syncs the log by
specifying the PULL parameter to log_write_header. I'm not sure
this is necessary anymore. It just seems to me there could be
cases where shutdown is called while there are outstanding log
buffers.
8. In the (data)buf_lo_before_commit functions, I changed some offset
values from being calculated on the fly to being constants. That
simplified some code and we might as well let the compiler do the
calculation once rather than redoing those cycles at run time.
9. This version has my rewritten databuf_lo_add function.
This version is much more like its predecessor, buf_lo_add, which
makes it easier to understand. Again, this might not be necessary,
but it seems as if this one works as well as the previous one,
maybe even better, so I decided to leave it in.
10. In databuf_lo_before_commit, a previous data corruption problem
was caused by going off the end of the buffer. The proper solution
is to have the proper limit in place, rather than stopping earlier.
(Thus my previous attempt to fix it is wrong).
If you don't wrap the buffer, you're stopping too early and that
causes more log buffer accounting problems.
11. In lops.h there are two new (previously mentioned) constants for
figuring out the data offset for the journal buffers.
12. There are also two new functions, buf_limit and databuf_limit to
calculate how many entries will fit in the buffer.
13. In function gfs2_meta_wipe, it needs to distinguish between pinned
metadata buffers and journaled data buffers for proper journal buffer
accounting. It can't use the JDATA gfs2_inode flag because it's
sometimes passed the "real" inode and sometimes the "metadata
inode" and the inode flags will be random bits in a metadata
gfs2_inode. It needs to base its decision on which was passed in.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2007-06-18 19:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
|
|
|
|
{
|
2020-12-05 12:21:50 +00:00
|
|
|
return sdp->sd_ldptrs / 2;
|
[GFS2] assertion failure after writing to journaled file, umount
This patch passes all my nasty tests that were causing the code to
fail under one circumstance or another. Here is a complete summary
of all changes from today's git tree, in order of appearance:
1. There are now separate variables for metadata buffer accounting.
2. Variable sd_log_num_hdrs is no longer needed, since the header
accounting is taken care of by the reserve/refund sequence.
3. Fixed a tiny grammatical problem in a comment.
4. Added a new function "calc_reserved" to calculate the reserved
log space. This isn't entirely necessary, but it has two benefits:
First, it simplifies the gfs2_log_refund function greatly.
Second, it allows for easier debugging because I could sprinkle the
code with calls to this function to make sure the accounting is
proper (by adding asserts and printks) at strategic point of the code.
5. In log_pull_tail there apparently was a kludge to fix up the
accounting based on a "pull" parameter. The buffer accounting is
now done properly, so the kludge was removed.
6. File sync operations were making a call to gfs2_log_flush that
writes another journal header. Since that header was unplanned
for (reserved) by the reserve/refund sequence, the free space had
to be decremented so that when log_pull_tail gets called, the free
space is be adjusted properly. (Did I hear you call that a kludge?
well, maybe, but a lot more justifiable than the one I removed).
7. In the gfs2_log_shutdown code, it optionally syncs the log by
specifying the PULL parameter to log_write_header. I'm not sure
this is necessary anymore. It just seems to me there could be
cases where shutdown is called while there are outstanding log
buffers.
8. In the (data)buf_lo_before_commit functions, I changed some offset
values from being calculated on the fly to being constants. That
simplified some code and we might as well let the compiler do the
calculation once rather than redoing those cycles at run time.
9. This version has my rewritten databuf_lo_add function.
This version is much more like its predecessor, buf_lo_add, which
makes it easier to understand. Again, this might not be necessary,
but it seems as if this one works as well as the previous one,
maybe even better, so I decided to leave it in.
10. In databuf_lo_before_commit, a previous data corruption problem
was caused by going off the end of the buffer. The proper solution
is to have the proper limit in place, rather than stopping earlier.
(Thus my previous attempt to fix it is wrong).
If you don't wrap the buffer, you're stopping too early and that
causes more log buffer accounting problems.
11. In lops.h there are two new (previously mentioned) constants for
figuring out the data offset for the journal buffers.
12. There are also two new functions, buf_limit and databuf_limit to
calculate how many entries will fit in the buffer.
13. In function gfs2_meta_wipe, it needs to distinguish between pinned
metadata buffers and journaled data buffers for proper journal buffer
accounting. It can't use the JDATA gfs2_inode flag because it's
sometimes passed the "real" inode and sometimes the "metadata
inode" and the inode flags will be random bits in a metadata
gfs2_inode. It needs to base its decision on which was passed in.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2007-06-18 19:50:20 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 15:22:35 +00:00
|
|
|
static inline void lops_before_commit(struct gfs2_sbd *sdp,
|
|
|
|
struct gfs2_trans *tr)
|
2006-01-16 16:50:04 +00:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
for (x = 0; gfs2_log_ops[x]; x++)
|
|
|
|
if (gfs2_log_ops[x]->lo_before_commit)
|
2014-02-21 15:22:35 +00:00
|
|
|
gfs2_log_ops[x]->lo_before_commit(sdp, tr);
|
2006-01-16 16:50:04 +00:00
|
|
|
}
|
|
|
|
|
GFS2: replace gfs2_ail structure with gfs2_trans
In order to allow transactions and log flushes to happen at the same
time, gfs2 needs to move the transaction accounting and active items
list code into the gfs2_trans structure. As a first step toward this,
this patch removes the gfs2_ail structure, and handles the active items
list in the gfs_trans structure. This keeps gfs2 from allocating an ail
structure on log flushes, and gives us a struture that can later be used
to store the transaction accounting outside of the gfs2 superblock
structure.
With this patch, at the end of a transaction, gfs2 will add the
gfs2_trans structure to the superblock if there is not one already.
This structure now has the active items fields that were previously in
gfs2_ail. This is not necessary in the case where the transaction was
simply used to add revokes, since these are never written outside of the
journal, and thus, don't need an active items list.
Also, in order to make sure that the transaction structure is not
removed while it's still in use by gfs2_trans_end, unlocking the
sd_log_flush_lock has to happen slightly later in ending the
transaction.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2013-04-06 01:31:46 +00:00
|
|
|
static inline void lops_after_commit(struct gfs2_sbd *sdp,
|
|
|
|
struct gfs2_trans *tr)
|
2006-01-16 16:50:04 +00:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
for (x = 0; gfs2_log_ops[x]; x++)
|
|
|
|
if (gfs2_log_ops[x]->lo_after_commit)
|
GFS2: replace gfs2_ail structure with gfs2_trans
In order to allow transactions and log flushes to happen at the same
time, gfs2 needs to move the transaction accounting and active items
list code into the gfs2_trans structure. As a first step toward this,
this patch removes the gfs2_ail structure, and handles the active items
list in the gfs_trans structure. This keeps gfs2 from allocating an ail
structure on log flushes, and gives us a struture that can later be used
to store the transaction accounting outside of the gfs2 superblock
structure.
With this patch, at the end of a transaction, gfs2 will add the
gfs2_trans structure to the superblock if there is not one already.
This structure now has the active items fields that were previously in
gfs2_ail. This is not necessary in the case where the transaction was
simply used to add revokes, since these are never written outside of the
journal, and thus, don't need an active items list.
Also, in order to make sure that the transaction structure is not
removed while it's still in use by gfs2_trans_end, unlocking the
sd_log_flush_lock has to happen slightly later in ending the
transaction.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
2013-04-06 01:31:46 +00:00
|
|
|
gfs2_log_ops[x]->lo_after_commit(sdp, tr);
|
2006-01-16 16:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void lops_before_scan(struct gfs2_jdesc *jd,
|
2006-10-14 01:47:13 +00:00
|
|
|
struct gfs2_log_header_host *head,
|
2006-01-16 16:50:04 +00:00
|
|
|
unsigned int pass)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
for (x = 0; gfs2_log_ops[x]; x++)
|
|
|
|
if (gfs2_log_ops[x]->lo_before_scan)
|
|
|
|
gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
|
|
|
|
}
|
|
|
|
|
2019-03-25 15:34:19 +00:00
|
|
|
static inline int lops_scan_elements(struct gfs2_jdesc *jd, u32 start,
|
2006-01-16 16:50:04 +00:00
|
|
|
struct gfs2_log_descriptor *ld,
|
|
|
|
__be64 *ptr,
|
|
|
|
unsigned int pass)
|
|
|
|
{
|
|
|
|
int x, error;
|
|
|
|
for (x = 0; gfs2_log_ops[x]; x++)
|
|
|
|
if (gfs2_log_ops[x]->lo_scan_elements) {
|
|
|
|
error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
|
|
|
|
ld, ptr, pass);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
|
|
|
|
unsigned int pass)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
for (x = 0; gfs2_log_ops[x]; x++)
|
|
|
|
if (gfs2_log_ops[x]->lo_before_scan)
|
|
|
|
gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __LOPS_DOT_H__ */
|
|
|
|
|