]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore/FileJournal: fail out if FileJournal is not block device or regular... 11929/head
authorKefu Chai <kchai@redhat.com>
Tue, 20 Sep 2016 09:39:24 +0000 (17:39 +0800)
committerNathan Cutler <ncutler@suse.com>
Sat, 12 Nov 2016 10:34:27 +0000 (11:34 +0100)
otherwise JournalingFileStore will assert when deleting FileJournal
which still has the non block/regular file opened.

Fixes: http://tracker.ceph.com/issues/17307
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 7431eec6fd24cd08ca6c76a9893e3f6e8c63a916)

src/os/FileJournal.cc

index 8c2635e2f9667f22096735352e4aea31060ceac5..43ace8fa0c865184daeb1ac19169ea4428a9fec6 100644 (file)
@@ -81,13 +81,17 @@ int FileJournal::_open(bool forwrite, bool create)
 
   if (S_ISBLK(st.st_mode)) {
     ret = _open_block_device();
-  } else {
+  } else if (S_ISREG(st.st_mode)) {
     if (aio && !force_aio) {
       derr << "FileJournal::_open: disabling aio for non-block journal.  Use "
           << "journal_force_aio to force use of aio anyway" << dendl;
       aio = false;
     }
     ret = _open_file(st.st_size, st.st_blksize, create);
+  } else {
+    derr << "FileJournal::_open: wrong journal file type: " << st.st_mode
+        << dendl;
+    ret = -EINVAL;
   }
 
   if (ret)
@@ -119,6 +123,7 @@ int FileJournal::_open(bool forwrite, bool create)
 
  out_fd:
   VOID_TEMP_FAILURE_RETRY(::close(fd));
+  fd = -1;
   return ret;
 }