Message ID | 1401193701.1304.135.camel@sauron.fi.intel.com |
---|---|
State | Accepted |
Headers | show |
Hi Artem, I think you made a small mistake: > spin_lock(&ui->ui_lock); > - ubifs_assert(page->index <= ui->synced_i_size << PAGE_CACHE_SIZE); > + ubifs_assert(page->index <= ui->synced_i_size >> PAGE_CACHE_SIZE); Here should be PAGE_CACHE_SHIFT, not PAGE_CACHE_SIZE. Thanks. Hu
On Wed, 2014-05-28 at 10:27 +0800, hujianyang wrote: > Hi Artem, > > I think you made a small mistake: Indeed, and not that small, even. I'll fix this, thanks! If I was writing this code now, I would not bother using shifts, I'd just use divisions, which are simpler and less error-prone. And modern compilers are smart enough to optimize the code to use shifts when the divider is a constant.
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 727506b..2767ffb 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -905,7 +905,7 @@ static int do_writepage(struct page *page, int len) #ifdef UBIFS_DEBUG struct ubifs_inode *ui = ubifs_inode(inode); spin_lock(&ui->ui_lock); - ubifs_assert(page->index <= ui->synced_i_size << PAGE_CACHE_SIZE); + ubifs_assert(page->index <= ui->synced_i_size >> PAGE_CACHE_SIZE); spin_unlock(&ui->ui_lock); #endif