disable some mediatekl custom warnings
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / cifs / file.c
index 7a0dd99e45077dfd2f7f780c140954575c9145a6..8b0c656f2ab26d79c10648fa38129bb38fc52265 100644 (file)
@@ -78,9 +78,8 @@ static u32 cifs_posix_convert_flags(unsigned int flags)
                if (flags & O_EXCL)
                        posix_flags |= SMB_O_EXCL;
        } else if (flags & O_EXCL)
-               cFYI(1, "Application %s pid %d has incorrectly set O_EXCL flag"
-                       "but not O_CREAT on file open. Ignoring O_EXCL",
-                       current->comm, current->tgid);
+               cifs_dbg(FYI, "Application %s pid %d has incorrectly set O_EXCL flag but not O_CREAT on file open. Ignoring O_EXCL\n",
+                        current->comm, current->tgid);
 
        if (flags & O_TRUNC)
                posix_flags |= SMB_O_TRUNC;
@@ -123,7 +122,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
        struct tcon_link *tlink;
        struct cifs_tcon *tcon;
 
-       cFYI(1, "posix open %s", full_path);
+       cifs_dbg(FYI, "posix open %s\n", full_path);
 
        presp_data = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
        if (presp_data == NULL)
@@ -308,7 +307,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
         */
        if (oplock == server->vals->oplock_read &&
                                                cifs_has_mand_locks(cinode)) {
-               cFYI(1, "Reset oplock val from read to None due to mand locks");
+               cifs_dbg(FYI, "Reset oplock val from read to None due to mand locks\n");
                oplock = 0;
        }
 
@@ -374,8 +373,8 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
        list_del(&cifs_file->tlist);
 
        if (list_empty(&cifsi->openFileList)) {
-               cFYI(1, "closing last open instance for inode %p",
-                       cifs_file->dentry->d_inode);
+               cifs_dbg(FYI, "closing last open instance for inode %p\n",
+                        cifs_file->dentry->d_inode);
                /*
                 * In strict cache mode we need invalidate mapping on the last
                 * close  because it may cause a error when we open this file
@@ -454,7 +453,7 @@ int cifs_open(struct inode *inode, struct file *file)
                goto out;
        }
 
-       cFYI(1, "inode = 0x%p file flags are 0x%x for %s",
+       cifs_dbg(FYI, "inode = 0x%p file flags are 0x%x for %s\n",
                 inode, file->f_flags, full_path);
 
        if (server->oplocks)
@@ -470,16 +469,13 @@ int cifs_open(struct inode *inode, struct file *file)
                                cifs_sb->mnt_file_mode /* ignored */,
                                file->f_flags, &oplock, &fid.netfid, xid);
                if (rc == 0) {
-                       cFYI(1, "posix open succeeded");
+                       cifs_dbg(FYI, "posix open succeeded\n");
                        posix_open_ok = true;
                } else if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
                        if (tcon->ses->serverNOS)
-                               cERROR(1, "server %s of type %s returned"
-                                          " unexpected error on SMB posix open"
-                                          ", disabling posix open support."
-                                          " Check if server update available.",
-                                          tcon->ses->serverName,
-                                          tcon->ses->serverNOS);
+                               cifs_dbg(VFS, "server %s of type %s returned unexpected error on SMB posix open, disabling posix open support. Check if server update available.\n",
+                                        tcon->ses->serverName,
+                                        tcon->ses->serverNOS);
                        tcon->broken_posix_open = true;
                } else if ((rc != -EIO) && (rc != -EREMOTE) &&
                         (rc != -EOPNOTSUPP)) /* path not found or net err */
@@ -557,11 +553,10 @@ cifs_relock_file(struct cifsFileInfo *cfile)
        struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
        int rc = 0;
 
-       /* we are going to update can_cache_brlcks here - need a write access */
-       down_write(&cinode->lock_sem);
+       down_read(&cinode->lock_sem);
        if (cinode->can_cache_brlcks) {
-               /* can cache locks - no need to push them */
-               up_write(&cinode->lock_sem);
+               /* can cache locks - no need to relock */
+               up_read(&cinode->lock_sem);
                return rc;
        }
 
@@ -572,7 +567,7 @@ cifs_relock_file(struct cifsFileInfo *cfile)
        else
                rc = tcon->ses->server->ops->push_mand_locks(cfile);
 
-       up_write(&cinode->lock_sem);
+       up_read(&cinode->lock_sem);
        return rc;
 }
 
@@ -621,8 +616,8 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
                return rc;
        }
 
-       cFYI(1, "inode = 0x%p file flags 0x%x for %s", inode, cfile->f_flags,
-            full_path);
+       cifs_dbg(FYI, "inode = 0x%p file flags 0x%x for %s\n",
+                inode, cfile->f_flags, full_path);
 
        if (tcon->ses->server->oplocks)
                oplock = REQ_OPLOCK;
@@ -643,7 +638,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
                                     cifs_sb->mnt_file_mode /* ignored */,
                                     oflags, &oplock, &fid.netfid, xid);
                if (rc == 0) {
-                       cFYI(1, "posix reopen succeeded");
+                       cifs_dbg(FYI, "posix reopen succeeded\n");
                        goto reopen_success;
                }
                /*
@@ -672,8 +667,8 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
                               NULL, cifs_sb);
        if (rc) {
                mutex_unlock(&cfile->fh_mutex);
-               cFYI(1, "cifs_reopen returned 0x%x", rc);
-               cFYI(1, "oplock: %d", oplock);
+               cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc);
+               cifs_dbg(FYI, "oplock: %d\n", oplock);
                goto reopen_error_exit;
        }
 
@@ -729,7 +724,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
        struct TCP_Server_Info *server;
        char *buf;
 
-       cFYI(1, "Closedir inode = 0x%p", inode);
+       cifs_dbg(FYI, "Closedir inode = 0x%p\n", inode);
 
        if (cfile == NULL)
                return rc;
@@ -738,7 +733,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
        tcon = tlink_tcon(cfile->tlink);
        server = tcon->ses->server;
 
-       cFYI(1, "Freeing private data in close dir");
+       cifs_dbg(FYI, "Freeing private data in close dir\n");
        spin_lock(&cifs_file_list_lock);
        if (!cfile->srch_inf.endOfSearch && !cfile->invalidHandle) {
                cfile->invalidHandle = true;
@@ -747,7 +742,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
                        rc = server->ops->close_dir(xid, tcon, &cfile->fid);
                else
                        rc = -ENOSYS;
-               cFYI(1, "Closing uncompleted readdir with rc %d", rc);
+               cifs_dbg(FYI, "Closing uncompleted readdir with rc %d\n", rc);
                /* not much we can do if it fails anyway, ignore rc */
                rc = 0;
        } else
@@ -755,7 +750,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
 
        buf = cfile->srch_inf.ntwrk_buf_start;
        if (buf) {
-               cFYI(1, "closedir free smb buf in srch struct");
+               cifs_dbg(FYI, "closedir free smb buf in srch struct\n");
                cfile->srch_inf.ntwrk_buf_start = NULL;
                if (cfile->srch_inf.smallBuf)
                        cifs_small_buf_release(buf);
@@ -1140,7 +1135,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
                         * The list ended. We don't have enough allocated
                         * structures - something is really wrong.
                         */
-                       cERROR(1, "Can't push all brlocks!");
+                       cifs_dbg(VFS, "Can't push all brlocks!\n");
                        break;
                }
                length = 1 + flock->fl_end - flock->fl_start;
@@ -1213,47 +1208,46 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock,
                bool *wait_flag, struct TCP_Server_Info *server)
 {
        if (flock->fl_flags & FL_POSIX)
-               cFYI(1, "Posix");
+               cifs_dbg(FYI, "Posix\n");
        if (flock->fl_flags & FL_FLOCK)
-               cFYI(1, "Flock");
+               cifs_dbg(FYI, "Flock\n");
        if (flock->fl_flags & FL_SLEEP) {
-               cFYI(1, "Blocking lock");
+               cifs_dbg(FYI, "Blocking lock\n");
                *wait_flag = true;
        }
        if (flock->fl_flags & FL_ACCESS)
-               cFYI(1, "Process suspended by mandatory locking - "
-                       "not implemented yet");
+               cifs_dbg(FYI, "Process suspended by mandatory locking - not implemented yet\n");
        if (flock->fl_flags & FL_LEASE)
-               cFYI(1, "Lease on file - not implemented yet");
+               cifs_dbg(FYI, "Lease on file - not implemented yet\n");
        if (flock->fl_flags &
            (~(FL_POSIX | FL_FLOCK | FL_SLEEP |
               FL_ACCESS | FL_LEASE | FL_CLOSE)))
-               cFYI(1, "Unknown lock flags 0x%x", flock->fl_flags);
+               cifs_dbg(FYI, "Unknown lock flags 0x%x\n", flock->fl_flags);
 
        *type = server->vals->large_lock_type;
        if (flock->fl_type == F_WRLCK) {
-               cFYI(1, "F_WRLCK ");
+               cifs_dbg(FYI, "F_WRLCK\n");
                *type |= server->vals->exclusive_lock_type;
                *lock = 1;
        } else if (flock->fl_type == F_UNLCK) {
-               cFYI(1, "F_UNLCK");
+               cifs_dbg(FYI, "F_UNLCK\n");
                *type |= server->vals->unlock_lock_type;
                *unlock = 1;
                /* Check if unlock includes more than one lock range */
        } else if (flock->fl_type == F_RDLCK) {
-               cFYI(1, "F_RDLCK");
+               cifs_dbg(FYI, "F_RDLCK\n");
                *type |= server->vals->shared_lock_type;
                *lock = 1;
        } else if (flock->fl_type == F_EXLCK) {
-               cFYI(1, "F_EXLCK");
+               cifs_dbg(FYI, "F_EXLCK\n");
                *type |= server->vals->exclusive_lock_type;
                *lock = 1;
        } else if (flock->fl_type == F_SHLCK) {
-               cFYI(1, "F_SHLCK");
+               cifs_dbg(FYI, "F_SHLCK\n");
                *type |= server->vals->shared_lock_type;
                *lock = 1;
        } else
-               cFYI(1, "Unknown type of lock");
+               cifs_dbg(FYI, "Unknown type of lock\n");
 }
 
 static int
@@ -1296,8 +1290,8 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
                                            type, 0, 1, false);
                flock->fl_type = F_UNLCK;
                if (rc != 0)
-                       cERROR(1, "Error unlocking previously locked "
-                                 "range %d during test of lock", rc);
+                       cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n",
+                                rc);
                return 0;
        }
 
@@ -1316,8 +1310,8 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
                        type | server->vals->shared_lock_type, 0, 1, false);
                flock->fl_type = F_RDLCK;
                if (rc != 0)
-                       cERROR(1, "Error unlocking previously locked "
-                                 "range %d during test of lock", rc);
+                       cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n",
+                                rc);
        } else
                flock->fl_type = F_WRLCK;
 
@@ -1508,8 +1502,8 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
                if (!CIFS_I(inode)->clientCanCacheAll &&
                                        CIFS_I(inode)->clientCanCacheRead) {
                        cifs_invalidate_mapping(inode);
-                       cFYI(1, "Set no oplock for inode=%p due to mand locks",
-                            inode);
+                       cifs_dbg(FYI, "Set no oplock for inode=%p due to mand locks\n",
+                                inode);
                        CIFS_I(inode)->clientCanCacheRead = false;
                }
 
@@ -1546,9 +1540,9 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
        rc = -EACCES;
        xid = get_xid();
 
-       cFYI(1, "Lock parm: 0x%x flockflags: 0x%x flocktype: 0x%x start: %lld "
-               "end: %lld", cmd, flock->fl_flags, flock->fl_type,
-               flock->fl_start, flock->fl_end);
+       cifs_dbg(FYI, "Lock parm: 0x%x flockflags: 0x%x flocktype: 0x%x start: %lld end: %lld\n",
+                cmd, flock->fl_flags, flock->fl_type,
+                flock->fl_start, flock->fl_end);
 
        cfile = (struct cifsFileInfo *)file->private_data;
        tcon = tlink_tcon(cfile->tlink);
@@ -1620,8 +1614,8 @@ cifs_write(struct cifsFileInfo *open_file, __u32 pid, const char *write_data,
 
        cifs_sb = CIFS_SB(dentry->d_sb);
 
-       cFYI(1, "write %zd bytes to offset %lld of %s", write_size,
-            *offset, dentry->d_name.name);
+       cifs_dbg(FYI, "write %zd bytes to offset %lld of %s\n",
+                write_size, *offset, dentry->d_name.name);
 
        tcon = tlink_tcon(open_file->tlink);
        server = tcon->ses->server;
@@ -1736,7 +1730,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
        it being zero) during stress testcases so we need to check for it */
 
        if (cifs_inode == NULL) {
-               cERROR(1, "Null inode passed to cifs_writeable_file");
+               cifs_dbg(VFS, "Null inode passed to cifs_writeable_file\n");
                dump_stack();
                return NULL;
        }
@@ -1848,7 +1842,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
                else if (bytes_written < 0)
                        rc = bytes_written;
        } else {
-               cFYI(1, "No writeable filehandles for inode");
+               cifs_dbg(FYI, "No writeable filehandles for inode\n");
                rc = -EIO;
        }
 
@@ -2015,7 +2009,7 @@ retry:
                        wdata->cfile = find_writable_file(CIFS_I(mapping->host),
                                                          false);
                        if (!wdata->cfile) {
-                               cERROR(1, "No writable handles for inode");
+                               cifs_dbg(VFS, "No writable handles for inode\n");
                                rc = -EBADF;
                                break;
                        }
@@ -2076,7 +2070,7 @@ cifs_writepage_locked(struct page *page, struct writeback_control *wbc)
 /* BB add check for wbc flags */
        page_cache_get(page);
        if (!PageUptodate(page))
-               cFYI(1, "ppw - page not up to date");
+               cifs_dbg(FYI, "ppw - page not up to date\n");
 
        /*
         * Set the "writeback" flag, and clear "dirty" in the radix tree.
@@ -2127,7 +2121,7 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
        else
                pid = current->tgid;
 
-       cFYI(1, "write_end for page %p from pos %lld with %d bytes",
+       cifs_dbg(FYI, "write_end for page %p from pos %lld with %d bytes\n",
                 page, pos, copied);
 
        if (PageChecked(page)) {
@@ -2191,13 +2185,13 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
 
        xid = get_xid();
 
-       cFYI(1, "Sync file - name: %s datasync: 0x%x",
-               file->f_path.dentry->d_name.name, datasync);
+       cifs_dbg(FYI, "Sync file - name: %s datasync: 0x%x\n",
+                file->f_path.dentry->d_name.name, datasync);
 
        if (!CIFS_I(inode)->clientCanCacheRead) {
                rc = cifs_invalidate_mapping(inode);
                if (rc) {
-                       cFYI(1, "rc: %d during invalidate phase", rc);
+                       cifs_dbg(FYI, "rc: %d during invalidate phase\n", rc);
                        rc = 0; /* don't care about it in fsync */
                }
        }
@@ -2233,8 +2227,8 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 
        xid = get_xid();
 
-       cFYI(1, "Sync file - name: %s datasync: 0x%x",
-               file->f_path.dentry->d_name.name, datasync);
+       cifs_dbg(FYI, "Sync file - name: %s datasync: 0x%x\n",
+                file->f_path.dentry->d_name.name, datasync);
 
        tcon = tlink_tcon(smbfile->tlink);
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) {
@@ -2262,7 +2256,7 @@ int cifs_flush(struct file *file, fl_owner_t id)
        if (file->f_mode & FMODE_WRITE)
                rc = filemap_write_and_wait(inode->i_mapping);
 
-       cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);
+       cifs_dbg(FYI, "Flush inode %p file %p rc %d\n", inode, file, rc);
 
        return rc;
 }
@@ -2359,7 +2353,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
                 unsigned long nr_segs, loff_t *poffset)
 {
        unsigned long nr_pages, i;
-       size_t copied, len, cur_len;
+       size_t bytes, copied, len, cur_len;
        ssize_t total_written = 0;
        loff_t offset;
        struct iov_iter it;
@@ -2414,14 +2408,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
 
                save_len = cur_len;
                for (i = 0; i < nr_pages; i++) {
-                       copied = min_t(const size_t, cur_len, PAGE_SIZE);
+                       bytes = min_t(const size_t, cur_len, PAGE_SIZE);
                        copied = iov_iter_copy_from_user(wdata->pages[i], &it,
-                                                        0, copied);
+                                                        0, bytes);
                        cur_len -= copied;
                        iov_iter_advance(&it, copied);
+                       /*
+                        * If we didn't copy as much as we expected, then that
+                        * may mean we trod into an unmapped area. Stop copying
+                        * at that point. On the next pass through the big
+                        * loop, we'll likely end up getting a zero-length
+                        * write and bailing out of it.
+                        */
+                       if (copied < bytes)
+                               break;
                }
                cur_len = save_len - cur_len;
 
+               /*
+                * If we have no data to send, then that probably means that
+                * the copy above failed altogether. That's most likely because
+                * the address in the iovec was bogus. Set the rc to -EFAULT,
+                * free anything we allocated and bail out.
+                */
+               if (!cur_len) {
+                       for (i = 0; i < nr_pages; i++)
+                               put_page(wdata->pages[i]);
+                       kfree(wdata);
+                       rc = -EFAULT;
+                       break;
+               }
+
+               /*
+                * i + 1 now represents the number of pages we actually used in
+                * the copy phase above. Bring nr_pages down to that, and free
+                * any pages that we didn't use.
+                */
+               for ( ; nr_pages > i + 1; nr_pages--)
+                       put_page(wdata->pages[nr_pages - 1]);
+
                wdata->sync_mode = WB_SYNC_ALL;
                wdata->nr_pages = nr_pages;
                wdata->offset = (__u64)offset;
@@ -2520,8 +2545,6 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
 
        BUG_ON(iocb->ki_pos != pos);
 
-       sb_start_write(inode->i_sb);
-
        /*
         * We need to hold the sem to be sure nobody modifies lock list
         * with a brlock that prevents writing.
@@ -2545,7 +2568,6 @@ cifs_writev(struct kiocb *iocb, const struct iovec *iov,
        }
 
        up_read(&cinode->lock_sem);
-       sb_end_write(inode->i_sb);
        return rc;
 }
 
@@ -2582,8 +2604,8 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
                 * an old data.
                 */
                cifs_invalidate_mapping(inode);
-               cFYI(1, "Set no oplock for inode=%p after a write operation",
-                    inode);
+               cifs_dbg(FYI, "Set no oplock for inode=%p after a write operation\n",
+                        inode);
                cinode->clientCanCacheRead = false;
        }
        return written;
@@ -2759,15 +2781,15 @@ cifs_uncached_read_into_pages(struct TCP_Server_Info *server,
                        /* enough data to fill the page */
                        iov.iov_base = kmap(page);
                        iov.iov_len = PAGE_SIZE;
-                       cFYI(1, "%u: iov_base=%p iov_len=%zu",
-                               i, iov.iov_base, iov.iov_len);
+                       cifs_dbg(FYI, "%u: iov_base=%p iov_len=%zu\n",
+                                i, iov.iov_base, iov.iov_len);
                        len -= PAGE_SIZE;
                } else if (len > 0) {
                        /* enough for partial page, fill and zero the rest */
                        iov.iov_base = kmap(page);
                        iov.iov_len = len;
-                       cFYI(1, "%u: iov_base=%p iov_len=%zu",
-                               i, iov.iov_base, iov.iov_len);
+                       cifs_dbg(FYI, "%u: iov_base=%p iov_len=%zu\n",
+                                i, iov.iov_base, iov.iov_len);
                        memset(iov.iov_base + len, '\0', PAGE_SIZE - len);
                        rdata->tailsz = len;
                        len = 0;
@@ -2827,7 +2849,7 @@ cifs_iovec_read(struct file *file, const struct iovec *iov,
                pid = current->tgid;
 
        if ((file->f_flags & O_ACCMODE) == O_WRONLY)
-               cFYI(1, "attempting read on write only file instance");
+               cifs_dbg(FYI, "attempting read on write only file instance\n");
 
        do {
                cur_len = min_t(const size_t, len - total_read, cifs_sb->rsize);
@@ -3006,7 +3028,7 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
                pid = current->tgid;
 
        if ((file->f_flags & O_ACCMODE) == O_WRONLY)
-               cFYI(1, "attempting read on write only file instance");
+               cifs_dbg(FYI, "attempting read on write only file instance\n");
 
        for (total_read = 0, cur_offset = read_data; read_size > total_read;
             total_read += bytes_read, cur_offset += bytes_read) {
@@ -3097,7 +3119,8 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
        xid = get_xid();
        rc = cifs_revalidate_file(file);
        if (rc) {
-               cFYI(1, "Validation prior to mmap failed, error=%d", rc);
+               cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n",
+                        rc);
                free_xid(xid);
                return rc;
        }
@@ -3150,7 +3173,7 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server,
        /* determine the eof that the server (probably) has */
        eof = CIFS_I(rdata->mapping->host)->server_eof;
        eof_index = eof ? (eof - 1) >> PAGE_CACHE_SHIFT : 0;
-       cFYI(1, "eof=%llu eof_index=%lu", eof, eof_index);
+       cifs_dbg(FYI, "eof=%llu eof_index=%lu\n", eof, eof_index);
 
        rdata->tailsz = PAGE_CACHE_SIZE;
        for (i = 0; i < nr_pages; i++) {
@@ -3160,15 +3183,15 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server,
                        /* enough data to fill the page */
                        iov.iov_base = kmap(page);
                        iov.iov_len = PAGE_CACHE_SIZE;
-                       cFYI(1, "%u: idx=%lu iov_base=%p iov_len=%zu",
-                               i, page->index, iov.iov_base, iov.iov_len);
+                       cifs_dbg(FYI, "%u: idx=%lu iov_base=%p iov_len=%zu\n",
+                                i, page->index, iov.iov_base, iov.iov_len);
                        len -= PAGE_CACHE_SIZE;
                } else if (len > 0) {
                        /* enough for partial page, fill and zero the rest */
                        iov.iov_base = kmap(page);
                        iov.iov_len = len;
-                       cFYI(1, "%u: idx=%lu iov_base=%p iov_len=%zu",
-                               i, page->index, iov.iov_base, iov.iov_len);
+                       cifs_dbg(FYI, "%u: idx=%lu iov_base=%p iov_len=%zu\n",
+                                i, page->index, iov.iov_base, iov.iov_len);
                        memset(iov.iov_base + len,
                                '\0', PAGE_CACHE_SIZE - len);
                        rdata->tailsz = len;
@@ -3248,8 +3271,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
        rc = 0;
        INIT_LIST_HEAD(&tmplist);
 
-       cFYI(1, "%s: file=%p mapping=%p num_pages=%u", __func__, file,
-               mapping, num_pages);
+       cifs_dbg(FYI, "%s: file=%p mapping=%p num_pages=%u\n",
+                __func__, file, mapping, num_pages);
 
        /*
         * Start with the page at end of list and move it to private
@@ -3379,7 +3402,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
        if (rc < 0)
                goto io_error;
        else
-               cFYI(1, "Bytes read %d", rc);
+               cifs_dbg(FYI, "Bytes read %d\n", rc);
 
        file_inode(file)->i_atime =
                current_fs_time(file_inode(file)->i_sb);
@@ -3417,7 +3440,7 @@ static int cifs_readpage(struct file *file, struct page *page)
                return rc;
        }
 
-       cFYI(1, "readpage %p at offset %d 0x%x",
+       cifs_dbg(FYI, "readpage %p at offset %d 0x%x\n",
                 page, (int)offset, (int)offset);
 
        rc = cifs_readpage_worker(file, page, &offset);
@@ -3484,7 +3507,7 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
        struct page *page;
        int rc = 0;
 
-       cFYI(1, "write_begin from %lld len %d", (long long)pos, len);
+       cifs_dbg(FYI, "write_begin from %lld len %d\n", (long long)pos, len);
 
        page = grab_cache_page_write_begin(mapping, index, flags);
        if (!page) {
@@ -3573,7 +3596,7 @@ static int cifs_launder_page(struct page *page)
                .range_end = range_end,
        };
 
-       cFYI(1, "Launder page: %p", page);
+       cifs_dbg(FYI, "Launder page: %p\n", page);
 
        if (clear_page_dirty_for_io(page))
                rc = cifs_writepage_locked(page, &wbc);
@@ -3593,8 +3616,8 @@ void cifs_oplock_break(struct work_struct *work)
 
        if (!cinode->clientCanCacheAll && cinode->clientCanCacheRead &&
                                                cifs_has_mand_locks(cinode)) {
-               cFYI(1, "Reset oplock to None for inode=%p due to mand locks",
-                    inode);
+               cifs_dbg(FYI, "Reset oplock to None for inode=%p due to mand locks\n",
+                        inode);
                cinode->clientCanCacheRead = false;
        }
 
@@ -3609,12 +3632,12 @@ void cifs_oplock_break(struct work_struct *work)
                        mapping_set_error(inode->i_mapping, rc);
                        cifs_invalidate_mapping(inode);
                }
-               cFYI(1, "Oplock flush inode %p rc %d", inode, rc);
+               cifs_dbg(FYI, "Oplock flush inode %p rc %d\n", inode, rc);
        }
 
        rc = cifs_push_locks(cfile);
        if (rc)
-               cERROR(1, "Push locks rc = %d", rc);
+               cifs_dbg(VFS, "Push locks rc = %d\n", rc);
 
        /*
         * releasing stale oplock after recent reconnect of smb session using
@@ -3625,7 +3648,7 @@ void cifs_oplock_break(struct work_struct *work)
        if (!cfile->oplock_break_cancelled) {
                rc = tcon->ses->server->ops->oplock_response(tcon, &cfile->fid,
                                                             cinode);
-               cFYI(1, "Oplock release rc = %d", rc);
+               cifs_dbg(FYI, "Oplock release rc = %d\n", rc);
        }
 }