[LU-6489] osd-ldiskfs checks s_maxbytes limits incorrectly Created: 23/Apr/15  Updated: 09/Jul/15  Resolved: 09/Jul/15

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.8.0
Fix Version/s: Lustre 2.8.0

Type: Bug Priority: Major
Reporter: John Hammond Assignee: Yang Sheng
Resolution: Fixed Votes: 0
Labels: easy, osd-ldiskfs

Issue Links:
Duplicate
is duplicated by LU-3732 osd_io.c:320:osd_do_bio()) ASSERTION(... Closed
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

See the !HAVE_LDISKFS_MAP_BLOCKS version of osd_ldiskfs_map_ext_inode_pages(). The extent_max_page_index comparison is not applied to the first page in the IO and IIUC the comparison should be against fp->index + clen rather than fp->index + i.

static int osd_ldiskfs_map_ext_inode_pages(struct inode *inode,
                                           struct page **page,
                                           int pages, unsigned long *blocks,
                                           int create)
{
        int blocks_per_page = PAGE_CACHE_SIZE >> inode->i_blkbits;
        int rc = 0, i = 0;
        struct page *fp = NULL;
        int clen = 0;
        pgoff_t extent_max_page_index;

        extent_max_page_index = inode->i_sb->s_maxbytes >> PAGE_SHIFT;

        CDEBUG(D_OTHER, "inode %lu: map %d pages from %lu\n",
                inode->i_ino, pages, (*page)->index);

        /* pages are sorted already. so, we just have to find
         * contig. space and process them properly */
        while (i < pages) {
                if (fp == NULL) {
                        /* start new extent */
                        fp = *page++;
                        clen = 1;
                        i++;
                        continue;
                } else if (fp->index + clen == (*page)->index) {
                        /* continue the extent */
                        page++;
                        clen++;
                        i++;
                        continue;
                }

                if (fp->index + i >= extent_max_page_index)
                        GOTO(cleanup, rc = -EFBIG);

The other version of osd_ldiskfs_map_inode_pages() looks better but also uses i instead of clen.

In practice this is OK because clients respect llli_maxbytes/lsm_maxbytes/ocd_maxbytes. If client checks are disabled then it's easy to submit IOs that exceed the 16T - 4K limits and cause LBUGs in osd_do_bio(). However dynamic layouts and HSM restore introduce TOCTTOU issues with lli_maxbytes based checks.



 Comments   
Comment by Gerrit Updater [ 08/May/15 ]

Yang Sheng (yang.sheng@intel.com) uploaded a new patch: http://review.whamcloud.com/14731
Subject: LU-6489 osd: check max_page_index correctly
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: f30a233260a67cca737a826504d00444c3c990b9

Comment by Gerrit Updater [ 08/Jul/15 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch http://review.whamcloud.com/14731/
Subject: LU-6489 osd-ldiskfs: check max_page_index correctly
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: e185617009748a94f6284920bb291670aee09e39

Comment by Yang Sheng [ 09/Jul/15 ]

Patch landed. Close this ticket.

Generated at Sat Feb 10 02:00:40 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.