If the user has turned on journalling, but left osd_journal_size at 0,
normally we would use the existing size of the journal without
modifications. If the journal doesn't exist (i.e., we are running
mkjournal()), we have to check for this condition and return an error.
We can't create a journal if we don't know what size that journal needs
to be.
This fixes a bug where an extremely small journal file was being
created, leading to an infinite loop in FileJournal::wrap_read_bl().
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
char buf[80];
dout(2) << "create " << fn << dendl;
+ if (g_conf.osd_journal_size == 0) {
+ dout(0) << "You must set a non-zero journal size in order to create a journal. "
+ "Set osd_journal_size." << dendl;
+ return -EINVAL;
+ }
+
int err = _open(true, true);
if (err < 0)
return err;
::read(fd, &fsid, sizeof(fsid));
::close(fd);
+ int ret = 0;
+
open_journal();
if (journal) {
- int err = journal->create();
- if (err < 0) {
+ ret = journal->create();
+ if (ret)
dout(0) << "mkjournal error creating journal on " << journalpath << dendl;
- } else {
+ else
dout(0) << "mkjournal created journal on " << journalpath << dendl;
- }
delete journal;
journal = 0;
}
- return 0;
+ return ret;
}