linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: boyu.mt@taobao.com
Cc: linux-ext4@vger.kernel.org
Subject: re: ext4: add journalled write support for inline data
Date: Wed, 14 Jan 2015 12:52:05 +0300	[thread overview]
Message-ID: <20150114095205.GA13096@mwanda> (raw)

Hello Tao Ma,

The patch 3fdcfb668fd7: "ext4: add journalled write support for
inline data" from Dec 10, 2012, leads to the following static checker
warning:

	fs/ext4/inode.c:1574 __ext4_journalled_writepage()
	warn: missing error code here? 'ext4_journalled_write_inline_data()' failed.

fs/ext4/inode.c
  1556  static int __ext4_journalled_writepage(struct page *page,
  1557                                         unsigned int len)
  1558  {
  1559          struct address_space *mapping = page->mapping;
  1560          struct inode *inode = mapping->host;
  1561          struct buffer_head *page_bufs = NULL;
  1562          handle_t *handle = NULL;
  1563          int ret = 0, err = 0;
  1564          int inline_data = ext4_has_inline_data(inode);
  1565          struct buffer_head *inode_bh = NULL;
  1566  
  1567          ClearPageChecked(page);
  1568  
  1569          if (inline_data) {
  1570                  BUG_ON(page->index != 0);
  1571                  BUG_ON(len > ext4_get_max_inline_size(inode));
  1572                  inode_bh = ext4_journalled_write_inline_data(inode, len, page);
  1573                  if (inode_bh == NULL)
  1574                          goto out;

Should we set an error code if we do a goto out?  Really, this would be
more readable if it were a direct return.  "return 0;" and
"return -ESOMETHING;" are easy to understand and obviously deliberate
but "goto out;" is ambiguous and a more complicated way of achieving the
same result.

  1575          } else {
  1576                  page_bufs = page_buffers(page);
  1577                  if (!page_bufs) {
  1578                          BUG();
  1579                          goto out;
  1580                  }
  1581                  ext4_walk_page_buffers(handle, page_bufs, 0, len,
  1582                                         NULL, bget_one);
  1583          }
  1584          /* As soon as we unlock the page, it can go away, but we have
  1585           * references to buffers so we are safe */
  1586          unlock_page(page);
  1587  
  1588          handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
  1589                                      ext4_writepage_trans_blocks(inode));
  1590          if (IS_ERR(handle)) {
  1591                  ret = PTR_ERR(handle);
  1592                  goto out;
  1593          }
  1594  
  1595          BUG_ON(!ext4_handle_valid(handle));
  1596  
  1597          if (inline_data) {
  1598                  BUFFER_TRACE(inode_bh, "get write access");
  1599                  ret = ext4_journal_get_write_access(handle, inode_bh);
  1600  
  1601                  err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
  1602  
  1603          } else {
  1604                  ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
  1605                                               do_journal_get_write_access);
  1606  
  1607                  err = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
  1608                                               write_end_fn);
  1609          }
  1610          if (ret == 0)
  1611                  ret = err;
  1612          EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
  1613          err = ext4_journal_stop(handle);
  1614          if (!ret)
  1615                  ret = err;
  1616  
  1617          if (!ext4_has_inline_data(inode))
  1618                  ext4_walk_page_buffers(NULL, page_bufs, 0, len,
  1619                                         NULL, bput_one);
  1620          ext4_set_inode_state(inode, EXT4_STATE_JDATA);
  1621  out:
  1622          brelse(inode_bh);
  1623          return ret;
  1624  }

regards,
dan carpenter

                 reply	other threads:[~2015-01-14  9:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150114095205.GA13096@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=boyu.mt@taobao.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).